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 from SO says it is possible, but I it doesn't say how exactly!

2 Answers 2


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

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

$ 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
  • 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.
    – Nishant
    Apr 25, 2019 at 19:51

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.