Index

docker compose

command line

start application using docker-compose.yaml
docker-compose up
stop all containers using docker-compose.yaml
docker-compose down
using a custom file name
docker-compose -f [file] up

yaml syntax

docker compose hello world
version: "3.7"
services:
  [name]:
    image: alpine
    container_name: [container-name]
setting a custom container name
version: "3.7"
services:
  [name]:
    image: alpine
specifying a custom command
services:
  [name]:
    image: alpine
    command: sh -c 'echo hello'
exposing ports
services:
  [name]:
    image: alpine
    ports: [ 80:80, 8000:8000 ]
mounting a volume
services: 
  [name]: 
    image: alpine
    volumes: [ .:/app ]
    command: cat /app/[file]