patterndockerMinor
Make container start if docker daemon or host system is restarted
Viewed 0 times
containerdockersystemmakerestartedhoststartdaemon
Problem
First off, I am new to Docker. I was able to create a container based off an image I had previously pulled, start it, but the container is stopped if the docker daemon or the host system are restarted.
So the question is, what is the next step (after creating a container) to make it persistent so that it is started automatically when the daemon is started or restarted?
Thank you in advance.
So the question is, what is the next step (after creating a container) to make it persistent so that it is started automatically when the daemon is started or restarted?
Thank you in advance.
Solution
You need to add a restart policy to your container.
example:
In this example, I am telling docker to always restart the hello-world container no matter what happens (and also run it in the background interactively). If you do a
example:
docker run -dit --restart=always hello-worldIn this example, I am telling docker to always restart the hello-world container no matter what happens (and also run it in the background interactively). If you do a
docker ps, you will see it keeps restarting. To revert this, you need to update the container restart policy like this:docker update --restart=no Code Snippets
docker run -dit --restart=always hello-worlddocker update --restart=no <CONTAINER_ID>Context
StackExchange DevOps Q#8256, answer score: 1
Revisions (0)
No revisions yet.