Why my Docker container's writable layer persists after the container exits?

Viewed 1411

Docker's storage overview documentation says:

  • The data doesn’t persist when that container is no longer running, and it can be difficult to get the data out of the container if another process needs it.
  • A container’s writable layer is tightly coupled to the host machine where the container is running. You can’t easily move the data somewhere else.
  • Writing into a container’s writable layer requires a storage driver to manage the filesystem. The storage driver provides a union filesystem, using the Linux kernel. This extra abstraction reduces performance as compared to using data volumes, which write directly to the host filesystem.

As you can see, the docs say, "The data doesn’t persist when that container is no longer running". So why isn't the data removed when I stop my container?

Action logs

1 Answers

As you've seen and the comments confirm, the data does persist in a stopped container. You can restart the container and see the data in the container specific filesystem. You can also use docker cp to extract those files from the container. I have submitted the following documentation PR to update the docs and remove any confusion (thank you for pointing out the wording).

Related