Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to files in docker container when host is shut down ungracefully?

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?

like image 253
dracz3 Avatar asked Dec 13 '22 08:12

dracz3


1 Answers

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.

like image 56
Dashrath Mundkar Avatar answered Dec 31 '22 13:12

Dashrath Mundkar