Bootstrap FreeKB - Docker - Restart a container using the docker run --restart option
Docker - Restart a container using the docker run --restart option

Updated:   |  Docker articles

When creating a container using the docker run command, the --restart option can be used to start the Docker container if the Docker server or daemon is restarted or if the host server is restarted. 

It is important to recognize that if you do not use the --restart option when creating or starting a Docker container using the docker run commandthe Docker container will NOT start up if the Docker server or daemon is restarted or if the host server is restarted. The restart options are:

  • no
  • on-failure:[max-retries]
  • always - The Docker container will be started if the Docker server or daemon is restarted or if the host server is restarted
  • unless-stopped - The Docker container will be started if the Docker server or daemon is restarted or if the host server is restarted as long as the Docker container was not manually stopped
docker run --restart unless-stopped my-container

 

After a Docker container has been created, the docker restart command can be used to restart the container.

docker restart my-container

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter fa46ae in the box below so that we can be sure you are a human.