Persistence in a disposable world.
WHAT HAPPENS TO DATA IN A CONTAINER
It disappears when the container is removed.
WHY
The writable layer belongs to the container, not the image.
WHAT THAT MEANS
Anything that must survive goes outside.
WHAT A VOLUME IS
Storage managed by the engine, mounted into the container.
WHAT A BIND MOUNT IS
A directory from the host, mounted in.
WHAT TO USE FOR APPLICATION DATA
A volume.
WHAT TO USE FOR DEVELOPMENT
A bind mount of your source, so changes appear immediately.
WHAT TO NEVER DO IN PRODUCTION
Bind-mount arbitrary host paths.
WHY
It breaks isolation and ties the container to one machine's layout.
WHAT TO BE CAREFUL WITH
Permissions, since the user inside may differ from the host's.
WHAT THAT PRODUCES
Files the container cannot write, or files on the host owned by an unexpected user.
WHAT TO DO
Set a consistent user, and ensure ownership matches.
WHAT TO PLAN
Backups of volumes.
WHY IT NEEDS SAYING
Containerised data is frequently treated as disposable, and then is not.
HOW TO BACK UP A VOLUME
Run a container mounting it, and archive its contents.
WHAT TO TEST
Restoring it.