Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2019-06-01T19:27:42.607Z
Answers: Glad to have been of help
Answers: gmolaire
Answers: CC BY-SA 4.0
Answers: 2019-05-30T13:26:16.373Z
Answers: 2019-05-30T13:26:16.373Z
Answers: gmolaire
Body: <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>
  
Comments: CC BY-SA 4.0
Comments: 2019-05-29T16:46:18.520Z
Comments: `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.
Comments: Zeitounator
Comments: CC BY-SA 4.0
Comments: 2019-06-01T16:51:22.610Z
Comments: @Zeitounator Thank you! You comment and the chosen answer were very helpful.
Comments: docker-noob
Tags: <docker>
Title: Make container start if docker daemon or host system is restarted
UserDisplayName: docker-noob
ThreadText: # 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](https://docs.docker.com/config/containers/start-containers-automatically/#use-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 <CONTAINER_ID>
  
  ```
  
  > **Comments:**
  > **username_2**: Glad to have been of help  
  
  ---
  
  