7

I have started a container with the option --rm, for example:

docker run --rm -it --name test bash

But now I want to keep the container on exit. Is there a way to cancel the --rm option on an already running container?

eedrah
  • 2,245
  • 18
  • 32
  • 1
    This is not possible, you can try to create an image from this, with commit. – Thomas Decaux Jun 20 '18 at 16:50
  • As it's already been mentioned, unfortunately not possible, however, you should look into mapping a volume into your container so you don't lose your work in the future. – user3483203 Jun 20 '18 at 17:25

2 Answers2

2

This is not possible.

An alternative that might suit you would be to commit your container as a new image and run that image in a new container.

YSC
  • 38,212
  • 9
  • 96
  • 149
  • Keep in mind that for windows containers you cannot commit a during container : `Error response from daemon: windows does not support commit when container is running` And you also cannot pause the container : `Error response from daemon: Cannot pause container f680327c0109a2895aea681ef59449cd3a620ced0396eb12074195473e543566: cannot pause Windows Server Containers` – El Bachir Apr 13 '23 at 12:47
  • Not great... For this reason and others, I still consider Docker on Windows a hack. – YSC Apr 14 '23 at 07:19
1

Probably detach and commit the running container is a good choice.

  1. detach from the running container: Ctrl+P, Ctrl+Q (for Ubuntu).
  2. commit the running container as a new image.
youngsend
  • 129
  • 1
  • 4