Dorokhov.codes
03. Docker Compose
docker-compose.yml
Be careful to not use special characters ($
) or if it’s needed than to escape it like $$
.
Restart option
no
is the default restart policy, and it does not restart a container under any circumstance.
restart: "no"
restart: always
restart: on-failure
restart: unless-stopped
When always
is specified, the container always restarts.
unless-stopped
always restarts a container, except when the container is stopped (manually or otherwise).
The on-failure
policy restarts a container if the exit code indicates an on-failure error.
Optionally, limit the number of times the Docker daemon attempts to restart the container using the :max-retries
option.
restart: on-failure:10