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
- Make sure you systm can handle it: https://www.jenkins.io/doc/book/installing/docker/
- Download Docker.
- Double-click InstallDocker.msi to run the installer.
- Follow the Install Wizard
- Click Finish to launch Docker.
- Docker starts automatically.
- 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.