Reputation: 117
Let's say I have a docker container running some application, that will sometimes write some data to a file in a folder, that is not mapped to the host. Given the host is shut down in an ungraceful way (like power cables pulled out), what happens to the files that are stored inside the container but not mapped to the host? Will they persist? Does it get removed?
Upvotes: 4
Views: 4935
Reputation: 83
If such power disconnects or crash happens to your system the container goes into stop state and whatever data you saved before power disconnect will stay inside the container file system as long as it is not terminated. You can as access your data again by re-starting that container.
But yes as Dashrath Mundkar and xxxvodnikxxx said in their answers in case of cluster environment of containers, it gets killed and new-one is started in its place so you will loose all your data if it is not stored in any persistent mounted storage.
Upvotes: 7
Reputation: 9184
The files are deleted. Containers are ephemeral in nature. When the container starts it creates a new writable layer on top of the image, and whatever changes you make are on that layer. If you are not storing/mapping that layer data to some persistent location, then once the container or Docker daemon or host machine restarts all the data is lost.
Upvotes: 14