DEV Community

Discussion on: How to persist data with docker compose

Collapse
 
wdburgdorf profile image
Ralf Longwitz

For both volumes and binds I find that changes to files/folders and added files/folders persist. But removed files and folders reappear after a compose down/up. Why is that? How can deletions be made to persist?

Collapse
 
darkmavis1980 profile image
Alessio Michelini

Maybe you have some process that it recreates them on startup?

Collapse
 
wdburgdorf profile image
Ralf Longwitz

Thanks, Alessio. So I assume this is not normal behviour? If there is such a process, how could I find out?

Thread Thread
 
darkmavis1980 profile image
Alessio Michelini

it could be either an init script in the docker-compose, or it could be something in your Dockerfile, or maybe one of the libraries you are using might do that on startup, it's hard to say unfortunately, but as far I know, it's not a normal behaviour

Thread Thread
 
wdburgdorf profile image
Ralf Longwitz

Thank you! I'll go check my files.

Collapse
 
wdburgdorf profile image
Ralf Longwitz

I believe I found the reason why this happens:
stackoverflow.com/questions/393176...
When running docker-compose, a completely new container is created, with all original files. Then the files that are in my bound volume are added to those files.
I still have not figured out how to do it right. Something about running an image with lots of parameters. Super confusing. I cannot believe that such a common need does not have a simple solution ...