Storage and networking, topic 13 of 41
The container's file system
A container writes to its own thin writable layer. That layer is slow for heavy writes, invisible to other containers, and removed with the container, so a database that keeps its files there loses them when the container is replaced.
Treat containers as disposable and keep state outside them: in a volume, a bind mount, or a service such as a managed database. A tmpfs mount holds files in memory only, for scratch data and secrets that must not reach disk.
On Opsfolk
Nothing of ours for this topic yet: an article is on its way.
Elsewhere
- Storage, in the Docker documentationOfficial
- tmpfs mountsOfficial