|

Running a local instance of Jenkins with Docker on Windows 10

Do you want to learn or play around with Jenkins CI? A great way is to run your own instance locally. You can use the same steps to run on a server. This example is with Windows however the steps to run on a Linux machine are the same except the installation instructions.

Installation

  1. Make sure you systm can handle it: https://www.jenkins.io/doc/book/installing/docker/
  2. Download Docker.
  3. Double-click InstallDocker.msi to run the installer.
  4. Follow the Install Wizard
  5. Click Finish to launch Docker.
  6. Docker starts automatically.
  7. Docker loads a “Welcome” window giving you tips and access to the Docker documentation.

Verify Install

Run the following command in your favorite terminal:

docker run hello-world

Run Jenkins

Replace ${JENKINS_MOUNT_DIRECTORY} with where you want to mount it to, for example c:\\jenkins_home. If you are using cygwin it would be /c/jenkins_home. It should automatically create the directory for you. If you are having permission issues try a different directory or creating it yourself.

docker run -p 8080:8080 -v ${JENKINS_MOUNT_DIRECTORY}:/var/jenkins_home -d --name jenkins jenkins/jenkins

The above will automatically download a docker image jenkins/jenkins and name it jenkins. It will bind it to port 8080 so you can access it from localhost:8080 in your browser. -v ${JENKINS_MOUNT_DIRECTORY}:/var/jenkins_home mounts your host directory to the home directory inside the container. This allows you to restart the container and not have the data refresh.

Navigate to: http://localhost:8080/ and you will be asked to “Unlock Jenkins”.

You need to get the password by running docker logs jenkins

You should see something around the top similar to:

Please use the following password to proceed to installation:

1f7decd4e31344f8be148c3bf62e7825

Copy the random value like above, yours will be different. Paste it into the box above.

THAT’S IT. You have a running instance of Jenkins locally. The only difference for running on linux is the installation steps and the mount directory structure.

Similar Posts