Compose restart policy

A Compose restart policy determines when Docker should automatically restart a container after it exits or the Docker daemon restarts. This course uses unless-stopped so production services can return after failures or machine reboots unless an operator explicitly stopped them.

Minimal example

yaml
services:
  api:
    image: ghcr.io/yashdagar/zomato-api:latest
    restart: unless-stopped
  worker:
    image: ghcr.io/yashdagar/zomato-worker:latest
    restart: unless-stopped

Learn this concept

Lesson 7.1 · Multi-stage Dockerfiles for Go

Used in exercises

Exercise 7.2 · Production container stack Exercise 7.7 · Nightly mysqldump and one restore test
Prerequisite conceptsDocker Compose