Launch Jenkins using Docker Compose

To launch a Jenkins server in a Docker container using Docker Compose, the following docker-compose.yml defines a Jenkins server with a persistent job configuration.

jenkins:
  image: "jenkins:alpine"
  ports:
    - 8080:8080
  volumes:
    - /var/jenkins_home

And start then start it:

docker-compose up

You should now have a Jenkins running on localhost:8080.

If you need a bash to change any configuration, start it like this:

docker exec -i -t jenkins_jenkins_1 /bin/bash