Reputation: 1053
Why Docker is designed that way? I can only think of only one reason: to avoid these 2 errors:
This SO question is perhaps one of the most-read answers for a newbie like me about this behavior when a container "exits". However, it doesn't explain the why.
Upvotes: 0
Views: 620
Reputation: 263866
If you are running containers correctly, there is nothing inside the container you want to keep. It should be noted that only tmpfs mounts are deleted on exit of a container. Other changes to the container filesystem are deleted when the container is removed. By replacing containers with new instances, going back to the initial image state, we force changes to go into code that builds the image and remove the management of state drift.
Looking at the various types of things that could be lost, here is where you should be saving those changes:
Upvotes: 2