~/Docker Auto Restart Containers

Jan 19, 2022


To have Docker containers restart automatically, use the --restart option when running a container. This ensures containers come back up after a crash or system reboot.

Example:

1
docker run --restart=always -d nginx

Restart policies:

You can also update restart policies on existing containers using:

1
docker update --restart=unless-stopped <container_name>

For details, see the Docker restart policy docs.

Tags: [docker]