How to start Docker containers automatically

subject: Docker · date: 2017-12-07

Use --restart flag when using the docker run command:

  • on-failure: restart the container if it exits due to an error
  • unless-stopped: restart the container unless it is explicitly stopped
  • always: always restart the container if it stops

For example:

$ docker run -dit --restart always hello-world

share this article