Skip to content

Instantly share code, notes, and snippets.

@nevergone
Last active December 7, 2021 13:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nevergone/9f5796cf5dc046393529cabb2559f3d5 to your computer and use it in GitHub Desktop.
Save nevergone/9f5796cf5dc046393529cabb2559f3d5 to your computer and use it in GitHub Desktop.
Docker compose with docker:dind
x-volumes:
&x-volumes
volumes:
- ./docker-repo:/var/lib/docker
- ./project:/app
services:
docker:
# Starts a Docker daemon at the DNS name "docker"
# Note:
# * This must be called "docker" to line up with the default
# TLS certificate name
# * DOCKER_TLS_CERTDIR defaults to "/certs
image: docker:dind
restart: always
privileged: yes
<<: *x-volumes
ports:
# expose port inside service container: 0.0.0.0:80
- "${DIND_TEST:-127.0.0.1:5555}:80"
docker-client:
# Provides a Docker client container, including the client
# certs generated by the docker:dind container, above.
# Notes:
# * The name of this container doesn't matter
# * The DOCKER_CERT_PATH defaults to /certs/client, the
# same path where the docker:dind image generates the
# client certificate (and that we've mounted inside this
# container).
# You can execute a shell inside this container by running:
# docker-compose exec docker-client sh
image: docker
restart: always
stdin_open: true
tty: true
logging:
driver: none
environment:
DOCKER_HOST: tcp://docker:2376
DOCKER_TLS_VERIFY: '1'
DOCKER_CERT_PATH: '/certs/client'
<<: *x-volumes
volumes:
certs:
@nevergone
Copy link
Author

@nevergone
Copy link
Author

Tested Docker version 20.10.11, build dea9396
And docker-compose version 1.29.2, build 5becea4c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment