3 ms·
"Volumes" are the Docker construct used to store persisted data. You use a volume when you want to decouple the lifecycle of your data with the lifecycle of the
by bkanber 10y ago
"Volumes" are the Docker construct used to store persisted data. You use a volume when you want to decouple the lifecycle of your data with the lifecycle of the app. You can either map the volume to a directory on the host (ie, map /var/lib/mysql to ~/data/mysql), or you can allow Docker to manage it (where it'll live in /var/lib/docker/volumes/blah/blah).
You don't upgrade a running container. Imagine that containers are immutable; to launch a new, upgraded version, you re-build the image in your build/dev environment, and re-launch the image into production. If you're using a volume, you get to use the same backing data.
It's rare that apt-get postinstall will affect any data that you would persist -- app-specific data you'd keep in the image/container, and mysql data for instance you don't really want apt touching anyway. But if a data migration is necessary you'd either manage it with a "utility container" (image that's designed to run a script then stop, rather than run and keep running).