8

Is there a quick way to save the state of a docker container started with the --rm flag, as if you didn't specify it?

dagelf
  • 1,468
  • 1
  • 14
  • 25
  • 2
    I'd try exporting the running container and importing it as a new image. That should keep your file system state. – Joachim Isaksson Jan 26 '16 at 08:46
  • 4
    Not at a computer where I can test right now, but something like `docker export -o temp ` and `docker import temp mycopy`. Then you should be able to just run the image `mycopy` as usual. – Joachim Isaksson Jan 26 '16 at 08:49
  • Does this answer your question? [Cancel --rm option on running docker container](https://stackoverflow.com/questions/50953286/cancel-rm-option-on-running-docker-container) – muru Apr 29 '21 at 11:08

1 Answers1

4

Only the upcoming 1.10 docker update command would be able to (eventually) do that (cancel a --rm option)

But the 1.10 version of that command only supports resource configs.
It will be extended though in the future.

So for now, this does not seem possible.
You would have to stop it and relaunch it with the right set of options.

Note: if the issue is that a volume referenced by that container would be lost if you stopped (and automatically remove) said container, know that you can re-attach that volume to a new container.

The docker export mentioned by Joachim Isaksson in the comments is one workaround, but it has limitation (ie it won't export volume)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    @Nishant That does not seem supported yet in https://docs.docker.com/engine/reference/commandline/update/. As an example, https://codeburst.io/how-to-start-docker-containers-automatically-ec0545c392e4 shows how to update the restart policy. But not amend the rm option. – VonC Apr 25 '19 at 19:44
  • Thanks, @Vonc. I will use the export option then. – Nishant Apr 25 '19 at 19:52