====== Docker Compose ======
This is an add-on for [[start|Docker]] where you can specify whole sets of services into a single file and start them at once. You can also port container setups to other servers more easily.
* [[https://docs.docker.com/compose/compose-file|docker-compose.yml]] reference
===== useful commands =====
^ inspect service | ''docker inspect $(docker-compose ps -q SERVICENAME)'' |
^ inspect all services | ''docker inspect $(docker-compose ps -q)'' |
^ execute something in a container | ''docker exec CONTAINERNAME COMMAND'' |
^ get a shell in a container | ''docker exec CONTAINERNAME sh'' |
^ show all mounted paths | ''docker inspect -f %%'{{ ..:index-.mounts-0-.source }}' $(docker-compose ps -q)%%'' |
===== build =====
==== force recreation ====
docker-compose build --no-cache
===== reverse proxy =====
* [[https://traefik.io/|Traefik]] – "the cloud native edge router"
* [[https://hub.docker.com/r/jwilder/nginx-proxy/|nginx-proxy]] + [[https://github.com/JrCs/docker-letsencrypt-nginx-proxy-companion|letsencrypt-nginx-proxy-companion]]
* [[https://github.com/Max-Sum/HA-proxy|HA-proxy]] – HAProxy variant of nginx-proxy
* [[https://github.com/lucaslorentz/caddy-docker-proxy|caddy-docker-proxy]] – Plugin for the Caddy webserver to automatically server docker pages
* [[https://www.envoyproxy.io/|Envoy]] – Edge and service proxy
==== jwilder ====
* [[https://github.com/jwilder/nginx-proxy/wiki/List-of-Supported-Environment-Variables|Environment Variables (Github Wiki)]]
version: '3'
services:
[…]
environment:
- VIRTUAL_HOST=example.tilde.fun
- LETSENCRYPT_HOST=example.tilde.fun
networks:
- webproxy
[…]
networks:
[…]
webproxy:
external: true
=== isn't able to connect to container ===
expose the port:
expose:
- "80"
([[https://github.com/jwilder/nginx-proxy/issues/802|source]])
=== reload nginx config ===
docker kill --signal=HUP docker-gen
([[https://github.com/jwilder/nginx-proxy/issues/377|source]])
===== troubleshooting =====
==== it should work, but it doesn't! ====
Maybe there's still a volume left over from ''docker-compose down''? Check with ''docker volume ls'' and remove with ''docker volume prune'' and ''docker volume rm''.
===== dos and donots =====
**Do not** mount the folder where your docker-compose.yml and env-files are into a container. If your container is breached, one could easily gain root access to the whole host system!
**Do** use a reverse proxy. It makes handling SSL certificates and load balancing much easier.