Answers: <p>Even though this is a year old...</p>
  <p>If the containers important data isn't in a volume mount already, you could always try copying the important content out of the still running container and mount it into your more permanent container.</p>
  <pre><code>docker cp &lt;container&gt;:/path/in/container /path/on/host
  docker run -it -v /path/on/host:/path/in/container ....
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2021-03-26T18:01:14.430Z
Answers: 2021-03-26T18:01:14.430Z
Answers: CompEng88
Answers: <p>No, docker will delete the container when it stops, and there's no update option to change that behavior. You can see this in the help output:</p>
  
  <pre><code>$ docker container update --help
  
  Usage:  docker container update [OPTIONS] CONTAINER [CONTAINER...]
  
  Update configuration of one or more containers
  
  Options:
        --blkio-weight uint16        Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
        --cpu-period int             Limit CPU CFS (Completely Fair Scheduler) period
        --cpu-quota int              Limit CPU CFS (Completely Fair Scheduler) quota
        --cpu-rt-period int          Limit the CPU real-time period in microseconds
        --cpu-rt-runtime int         Limit the CPU real-time runtime in microseconds
    -c, --cpu-shares int             CPU shares (relative weight)
        --cpus decimal               Number of CPUs
        --cpuset-cpus string         CPUs in which to allow execution (0-3, 0,1)
        --cpuset-mems string         MEMs in which to allow execution (0-3, 0,1)
        --kernel-memory bytes        Kernel memory limit
    -m, --memory bytes               Memory limit
        --memory-reservation bytes   Memory soft limit
        --memory-swap bytes          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
        --pids-limit int             Tune container pids limit (set -1 for unlimited)
        --restart string             Restart policy to apply when a container exits
  </code></pre>
  
  <p>Trying to change the restart policy will result in an error:</p>
  
  <pre><code>$ docker run --rm --name test-rm -d busybox tail -f /dev/null                                                                                                                                                                                 
  14a7d9bfebc3356652e3c3f060e92d9cebb9f3eb4490873540c9eb1c272f6612
  
  $ docker update --restart=unless-stopped test-rm
  Error response from daemon: Cannot update container 14a7d9bfebc3356652e3c3f060e92d9cebb9f3eb4490873540c9eb1c272f6612: Restart policy cannot be updated because AutoRemove is enabled for the container
  </code></pre>
  
  <p>You can try to copy your data out of the container with:</p>
  
  <pre><code>docker container cp $container_name:/path/in/container /path/on/host
  </code></pre>
  
  <p>If you don't know which files to save, list which files have changed in the container with:</p>
  
  <pre><code>docker container diff $container_name
  </code></pre>
  
Answers: CC BY-SA 4.0
Answers: 2019-04-25T19:51:36.890Z
Answers: Thanks, @BMitch. `docker export` seems be a good option as mentioned in the linked question. I will try to see the diff to get an idea.
Answers: Nishant
Answers: CC BY-SA 4.0
Answers: 2019-04-25T19:49:06.610Z
Answers: 2019-04-25T19:51:54.930Z
Answers: 2019-04-25T19:51:54.930Z
Answers: BMitch
Body: <p>I started my docker container with <code>--rm</code> and <code>-it</code> options. I need to keep that container now because it has some important data. Can I cancel the <code>--rm</code> switch using the <code>docker update</code> command?</p>
  
  <p>This <a href="https://stackoverflow.com/questions/35009621/i-started-a-docker-container-with-rm-is-there-an-easy-way-to-keep-it-without">answer</a> from SO says it is possible, but I it doesn't say how exactly!</p>
  
Tags: <docker>
Title: Can I keep a container started with --rm option?
UserDisplayName: Nishant
ThreadText: # Can I keep a container started with --rm option?
  
  (Asked by: username_0 on 2019-04-25)
  
  I started my docker container with `--rm` and `-it` options. I need to keep that container now because it has some important data. Can I cancel the `--rm` switch using the `docker update` command?
  
  This [answer](https://stackoverflow.com/questions/35009621/i-started-a-docker-container-with-rm-is-there-an-easy-way-to-keep-it-without) from SO says it is possible, but I it doesn't say how exactly!
  
  **Tags:** docker
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2019-04-25. Score: 3 | Accepted answer
  
  No, docker will delete the container when it stops, and there's no update option to change that behavior. You can see this in the help output:
  
  ```
  $ docker container update --help
  
  Usage:  docker container update [OPTIONS] CONTAINER [CONTAINER...]
  
  Update configuration of one or more containers
  
  Options:
        --blkio-weight uint16        Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
        --cpu-period int             Limit CPU CFS (Completely Fair Scheduler) period
        --cpu-quota int              Limit CPU CFS (Completely Fair Scheduler) quota
        --cpu-rt-period int          Limit the CPU real-time period in microseconds
        --cpu-rt-runtime int         Limit the CPU real-time runtime in microseconds
    -c, --cpu-shares int             CPU shares (relative weight)
        --cpus decimal               Number of CPUs
        --cpuset-cpus string         CPUs in which to allow execution (0-3, 0,1)
        --cpuset-mems string         MEMs in which to allow execution (0-3, 0,1)
        --kernel-memory bytes        Kernel memory limit
    -m, --memory bytes               Memory limit
        --memory-reservation bytes   Memory soft limit
        --memory-swap bytes          Swap limit equal to memory plus swap: '-1' to enable unlimited swap
        --pids-limit int             Tune container pids limit (set -1 for unlimited)
        --restart string             Restart policy to apply when a container exits
  
  ```
  
  Trying to change the restart policy will result in an error:
  
  ```
  $ docker run --rm --name test-rm -d busybox tail -f /dev/null                                                                                                                                                                                 
  14a7d9bfebc3356652e3c3f060e92d9cebb9f3eb4490873540c9eb1c272f6612
  
  $ docker update --restart=unless-stopped test-rm
  Error response from daemon: Cannot update container 14a7d9bfebc3356652e3c3f060e92d9cebb9f3eb4490873540c9eb1c272f6612: Restart policy cannot be updated because AutoRemove is enabled for the container
  
  ```
  
  You can try to copy your data out of the container with:
  
  ```
  docker container cp $container_name:/path/in/container /path/on/host
  
  ```
  
  If you don't know which files to save, list which files have changed in the container with:
  
  ```
  docker container diff $container_name
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks, @username_2. `docker export` seems be a good option as mentioned in the linked question. I will try to see the diff to get an idea.  
  
  ---
  
  ### Answer by username_1 on 2021-03-26. Score: 3
  
  Even though this is a year old...
  
  If the containers important data isn't in a volume mount already, you could always try copying the important content out of the still running container and mount it into your more permanent container.
  
  ```
  docker cp <container>:/path/in/container /path/on/host
  docker run -it -v /path/on/host:/path/in/container ....
  
  ```
  
  
  ---
  
  