Difficulty: Advanced
Estimated Time: 15-20 minutes

In this scenario you'll learn how to configure Jenkins to build Docker Images based on a Dockerfile. The scenario is designed to demostrate how you can use Docker within a CI/CD pipeline, using Images as a build artefact that can be promoted to different environments and finally production.

The environment pre-configured and running Jenkins build server for you to experiment and learn how it works. The steps guide you to installing the plugin, creating a build and viewing the results.

Once the build has completed you should see the Image and Tags using the Docker CLI docker images.

What was built into the Docker Image was a small HTTP server. You can launch it using: docker run -d -p 80:80 katacoda/jenkins-demo:latest

Using cURL you should see the server respond: curl docker

Jenkins will have the console output of our build, available via the dashboard. You should be able to access it below:


If you rebuilt the project, you would see a version 2 image created and the :latest tag reattached.

Building Docker Images using Jenkins

Step 1 of 6

Launch Jenkins

Launch Jenkins

Launch Jenkins as a Docker Container with the following command:

docker run -d -u root --name jenkins \ -p 8080:8080 -p 50000:50000 \ -v /root/jenkins:/var/jenkins_home \ jenkins:1.651.1-alpine

All plugins and configurations get persisted to the host (ssh [email protected]) at /root/jenkins. Port 8080 opens the web dashboard, 50000 is used to communicate with other Jenkins agents. Finally, the image has an alpine base to reduce the size footprint.

Load Dashboard

You can load the Jenkins' dashboard via the following URL https://[[HOST_SUBDOMAIN]]-8080-[[KATACODA_HOST]].environments.katacoda.com/

The username is admin with the password the default 344827fbdbfb40d5aac067c7a07b9230

On your own system, the password can befound via docker exec -it jenkins cat /var/jenkins_home/secrets/initialAdminPassword

It may take a couple of seconds for Jenkins to finish starting and be available. In next steps, you'll use the dashboard to configure the plugins and start building Docker Images.