<p>You need to add a <a href="https://docs.docker.com/config/containers/start-containers-automatically/#use-a-restart-policy" rel="nofollow noreferrer">restart policy</a> to your container.</p>

<p>example:</p>

<pre><code>docker run -dit --restart=always hello-world
</code></pre>

<p>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 <code>docker ps</code>, you will see it keeps restarting. To revert this, you need to update the container restart policy like this:</p>

<pre><code>docker update --restart=no &lt;CONTAINER_ID&gt;
</code></pre>

CC BY-SA 4.0
2019-06-01T19:27:42.607Z
Glad to have been of help
gmolaire
CC BY-SA 4.0
2019-05-30T13:26:16.373Z
2019-05-30T13:26:16.373Z
gmolaire
<p>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.</p>

<p>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?</p>

<p>Thank you in advance.</p>

CC BY-SA 4.0
2019-05-29T16:46:18.520Z
`docker run --help | grep restart` combined with a reading of [the fine manual](https://docs.docker.com/config/containers/start-containers-automatically/) should get you going in minutes.
Zeitounator
CC BY-SA 4.0
2019-06-01T16:51:22.610Z
@Zeitounator Thank you! You comment and the chosen answer were very helpful.
docker-noob
<docker>
Make container start if docker daemon or host system is restarted
docker-noob
# Make container start if docker daemon or host system is restarted

(Asked by: username_0 on 2019-05-29)

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.

**Tags:** docker

> **Comments:**
> **username_1**: `docker run --help | grep restart` combined with a reading of [the fine manual](https://docs.docker.com/config/containers/start-containers-automatically/) should get you going in minutes.  
> **username_0**: @username_1 Thank you! You comment and the chosen answer were very helpful.  

---

## 1 answers

### Answer by username_2 on 2019-05-30. Score: 1 | Accepted answer

You need to add a restart policy to your container.
example:
docker run -dit --restart=always hello-world

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 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

> **Comments:**
> **username_2**: Glad to have been of help  

---

