Continuous Deployment on Jenkins and Docker

Miguel Ángel García Martínez

What are we going to see?

  • Jenkins
  • Docker
  • Docker-Compose
  • Continuous Integration
  • Continuous Deployment


Individuals and interactions over processes and tools

How are we going to do that?

  • Running a Jenkins server
  • Configuring a little project
  • Testing and deploying when it changes

How are we going to do that, exactly?

  • Run Jenkins server
  • Run Jenkins server on Docker
  • Configure the job te be launched
  • Run jenkins-swarm slave
  • Run jenkins-swarm slave on Docker
  • Create a docker-compose with both
  • Add master branch continuous integration

All of this in 5 minutes

Installing Jenkins:

 java -jar jenkins.war


Yes, it requires java

Jenkins landing page

Installing Jenkins, Docker mode:

 docker run -p 8080:8080 -p 50000:50000 jenkins

Docker glossary:

  • Image: like a class
  • Container: like an object
  • Volume: a mount point

Docker in a nutshell:

  • docker images Shows all downloaded images
  • docker ps Shows all running containers
  • docker ps -a Shows all created containers
  • docker run <image>
    download the image if necessary, create a container and run it.
  • docker exec -ti <container> <command>
    Executes the command on container

Configuring a job in jenkins:


  • How to prevent installing python, ruby, java, etc. in the same host?
  • How to prevent installing two different versions of python, ruby, java, etc. in the same host?
  • How to prevent installing two different versions of a library?
  • How to migrate the current infrastructure to production?
  • Get rid of packaging systems, like deb, rpm, ...

Our own image (reduced)

FROM java:8-jdk
RUN apt-get update \
    && apt-get install -y \
               git \
               wget \
               python3 \
RUN apt-get clean
RUN wget http://[...]/swarm-client-2.0-jar-with-dependencies.jar

COPY /usr/local/bin/

VOLUME /home/jenkins-slave

ENTRYPOINT ["/usr/local/bin/"]


  • Allows us to create a default docker configuration
  • Allows us to create a network of dockers
  • And all of this in a simple YAML file


version: '2'
    image: jenkins:2.7.1
      - 8080:8080
      - ./data/master:/var/jenkins_home

    build: slave
    command: -master http://master:8080 -executors 1
      -labels python -name builder
      -username swarm -password swarm
      - master


What does we have?

What does we want?


  • Database preloaded data
  • Third party services (RabbitMQ, ...)
  • New development requirements
  • Security issues