Created
June 21, 2020 00:17
-
-
Save adelmofilho/5a30a87eaf1cd4a03052f37b516d6714 to your computer and use it in GitHub Desktop.
Docker-in-Docker approach to run Jenkins as a Docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This docker-compose file intent to create a multi-container application | |
# that runs a Jenkins container connected via TLS to a Docker-in-Docker (dind) container as Docker daemon. | |
# | |
# Advice about this approach can be found at: | |
# http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/ | |
# | |
# As well discussion about another alternatives on this setup can be found at: | |
# https://forums.docker.com/t/using-docker-in-a-dockerized-jenkins-container/322/11 | |
# | |
# Quick reference about Docker-in-Docker can be fount at: | |
# https://hub.docker.com/_/docker | |
# | |
# Main source: https://www.jenkins.io/doc/tutorials/create-a-pipeline-in-blue-ocean/ | |
version: '3.1' | |
networks: | |
docker: | |
volumes: | |
jenkins-data: | |
jenkins-docker-certs: | |
services: | |
jenkins: | |
image: jenkinsci/blueocean | |
restart: always | |
networks: | |
- docker | |
ports: | |
- 8080:8080 | |
- 50000:50000 | |
tty: true | |
volumes: | |
- jenkins-data:/var/jenkins_home | |
- jenkins-docker-certs:/certs/client:ro | |
- $HOME:/home | |
environment: | |
- DOCKER_HOST=tcp://docker:2376 | |
- DOCKER_CERT_PATH=/certs/client | |
- DOCKER_TLS_VERIFY=1 | |
dind: | |
image: docker:dind | |
privileged: true | |
restart: always | |
networks: | |
docker: | |
aliases: | |
- docker | |
ports: | |
- 2376:2376 | |
tty: true | |
volumes: | |
- jenkins-data:/var/jenkins_home | |
- jenkins-docker-certs:/certs/client | |
- $HOME:/home | |
environment: | |
- DOCKER_TLS_CERTDIR=/certs |
ty, my dier friend, for this file!
give also volume for docker storage
dind:
# ...
volumes:
- docker-graph-storage:/var/lib/docker
volumes:
# ...
docker-graph-storage:
Enjoy as well
Thank you guy, it works well on my machine.
@abdennour what is that volume used for?
Thank you guy. It work well on My Machine. Mac Pro Silicon chip M2. 13.3.1 (22E261)
How do I get the actual ssl certificate in the right place in the Docker Container?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That worked well. Thank you!