services:
app:
image: myorg/app:1.4
restart: unless-stopped
ports: ["127.0.0.1:8080:8080"]
environment:
- LOG_LEVEL=info
volumes:
- appdata:/data
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8080/health"]
interval: 30s
timeout: 5s
retries: 3
volumes:
appdata:
docker compose up -d # create/update and start
docker compose ps
docker compose logs -f app
docker compose pull && docker compose up -d # update images
docker compose down # stop and remove containers (keeps named volumes)
docker compose down -v # ...and the volumes: deletes data!
docker compose config # validate and print the merged file
Pin image versions rather than latest. Publishing on 127.0.0.1: keeps a port private to the host (put a reverse proxy in front).