Install Jenkins On Docker

/ Comments off
  1. Install Jenkins On Docker Mac
  2. Installing Jenkins On Docker On Windows 10
  3. Install Jenkins On Docker Compose

In this first tutorial in the Docker series, you’ll learn:

  • What we’re trying to accomplish at Riot

  • Basic setup for Docker

  • Basic Docker Pull Commands

  • How to run Docker Containers as Daemons

  • Basic Jenkins configuration options

Install Jenkins with Docker file & preinstalled plugins. Copy existing.jpi/.hpi file to docker image. Step 2: First, pull the official jenkins image from Docker repository. $ docker pull jenkins. Step 3: Next, run a container using this image and map data directory from the container to the host; e.g in the example below /var/jenkinshome from the container is mapped to jenkins/ directory from the current path on the host. To stop Jenkins, you can go to the terminal window where you started the Docker container and hit Command + C. This will stop the process running the Docker container thus stopping Jenkins. If you need to start Jenkins again, run the exact same command as when you have installed Jenkins.

When I first started learning about Docker a year ago and exploring its use I had trouble finding great documentation and examples - even today many describe simple use cases that ultimately aren’t production ready. Productionizing applications with Docker containers requires adjusting to their ephemeral nature and single-process focus. This presents challenges to applications with data persistence needs or multi-process architectures.

As I mentioned in my last post, we use Jenkins as a foundational piece of open source software on top of which we build our automation. Jenkins is also a great application to demonstrate one way to think about “Dockerizing” your applications. We deploy Jenkins with these architectural components in mind:

Install Jenkins On Docker Mac

  • Jenkins master server (Java process)

  • Jenkins master data (Plugins, Job Definitions, etc)

  • NGINX web proxy (we use SSL certs etc, with NGINX is an easy choice here)

  • Build slave agents (machines either being SSH’d into, or JNLP connecting to, Jenkins Master)

This is a good place to start. Over this series of blog posts I’ll be covering ways to think about all of the above as containers and finish with an advanced look at ways to use Docker containers as build slaves. For starters, we’ll create a Jenkins master server in a Docker container. Then we’ll move on to dealing with data persistence and adding a web proxy with NGINX.

This entire blog series will cover the following Docker concepts:

  • Making your own Dockerfiles

  • Minimizing image dependencies on public images

  • Creating and using

Now build your image one more time

Let’s test our new image and if we can tail the log file! Try the following commands

With the container running we can tail the log file if everything worked


Time for a bonus round! As long as we’re discussing logs, Docker presents an interesting problem if Jenkins crashes. The container will stop running and docker exec will no longer work. So what to do?

We’ll discuss more advanced ways of persisting the log file later. For now, because the container is stopped we can copy files out of it using the dockercp command. Let’s simulate a crash by stopping the container, then retrieving the logs:

1. ctrl-c to exit out of the log file tail

2. Run the following commands


You can find all the work in my tutorial Git repo (and the updated convenience makefile) here:

By making our own Dockerfile that wraps the Cloudbees file, we were able to make life a little easier for ourselves. We set up a convenient place to store the logs and learned how to look at them with the docker exec command. We moved our default settings into the Dockerfile and now we can store this in source control as a good piece of self-documentation.

We still have a data persistence challenge. We’ve learned how to pull log files out of a stopped container (handy when Jenkins crashes). But in general if our container stops we’re still losing all the jobs we created. So without persistence, this Jenkins image is only useful for local development and testing.

Install Jenkins On Docker

That leads us to the next article. With our foundations in place - our own Dockerfile wrapper, locked to a handy version of Jenkins - we can solve the persistence problem. The next article will explore these concepts:

  • Preserving Jenkins Job and Plugin data

  • Docker Data Persistence with Volumes

  • Making a Data-Volume container

  • Sharing data in volumes with other containers

Installing Jenkins On Docker On Windows 10

For more information, check out the rest of this series:


Part I: Thinking Inside the Container
Part II: Putting Jenkins in a Docker Container (this article)
Part III: Docker & Jenkins: Data That Persists
Part IV: Jenkins, Docker, Proxies, and Compose
Part V: Taking Control of Your Docker Image
Part VI: Building with Jenkins Inside an Ephemeral Docker Container
Part VII: Tutorial: Building with Jenkins Inside an Ephemeral Docker Container
Part VIII: DockerCon Talk and the Story So Far

Install Jenkins On Docker Compose

Please enable JavaScript to view the comments powered by Disqus.