how-to ยท docker

How-to automatically restart docker container if it down?


You have an unstable Docker container and need restart it automatically when it down.


Docker has useful parameter --restart with three options:

  • no - do not restart container, default behavior
  • always - restart container on every shutting down
  • on-failure - restart container only if it exit with code != 0

So you should only add flag --restart=always when starting container.
If you use docker-compose you can add line restart:always

Read also

Docker run command
Compose file reference

comments powered by Disqus