6

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
  • 1,820
  • 14
  • 29
  • 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
  • 36,217
  • 8
  • 89
  • 142
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
  • 61
  • 1
  • 3