Comment on How to manage docker compose apps?

<- View Parent
suicidaleggroll@lemmy.world ⁨2⁩ ⁨days⁩ ago

There are two ways to maintain a persistent data store for Docker containers: bind mounts and docker-managed volumes.

A Docker managed volume looks like: datavolume:/data And then later on in the compose file you’ll have volumes: datavolume:

When you start this container, Docker will create this volume for you in /var/lib/docker/volumes/ and will manage access and permissions. They’re a little easier in that Docker handles permissions for you, but they’re also kind of a PITA because now your compose file and your data are split apart in different locations and you have to spend time tracking down where the hell Docker decided to put the volumes for your service, especially when it comes to backups/migration.

A bind mount looks like: ./datavolume:/data

When you start this container, if it doesn’t already exist, “datavolume” will be created in the same location as your compose file, and the data will be stored there. This is a little more manual since some containers don’t set up permissions properly and, once the volume is created, you may have to shut down the container and then chown the volume so it can use it, but once up and running it makes things much more convenient, since now all of the data needed by that service is in a directory right next to the compose file.

source
Sort:hotnewtop