admin:linux:docker:compose

Docker Compose

This is an add-on for 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.

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)
docker-compose build --no-cache
/srv/docker/service/docker-compose.yml
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:

docker-compose.yml
    expose:
      - "80"

(source)

reload nginx config

docker kill --signal=HUP docker-gen

(source)

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.

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.

  • Last modified: 2019-12-22 17:06