Docker Compose Tip #26: Using restart policies effectively
Keep your services running! Restart policies ensure containers recover from crashes automatically. Available restart policies Docker Compose offers four restart options: services: # Never restart (default) dev-tool: image: debug-tools restart: "no" # Restart only on failure (non-zero exit) api: image: api:latest restart: on-failure # Always restart unless manually stopped web: image: nginx restart: unless-stopped # Always restart, even after Docker daemon restarts database: image: postgres:15 restart: always Choosing the right policy Development services: ...