Question about volumes in compose: What's up about those paths?

Hey there;
I absolutely don’t get, whats up with the paths when you want to run docker compose and got something like:

volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro

What does the first path mean… and what does the second path after “:” mean? The only thing I understand is, that somehow directories (?) get … “connected”? One of your local directories with one of your container… is that right?

But for what is this good for? Only if you want to access files of your container easily?

Am I able to change the paths and what should I be carefull about?

I really tried to understand https://docs.docker.com/compose/compose-file/07-volumes/#example, but either I’m to stupid or the explanation is bad formulated.

I really would be thankful, if someone could explain it to me :slight_smile:

Left side: source on host
Right side: target in container

So for example in

volumes:
- ./gitea:/data

I can change the left side how i want, but the right side should stay the same? (because the documentation of gitea tells you to use /data)

Never change the container path to something else than what it says in the image description, unless you know what you are doing, and know how to configure the container to work with the changed container path.

Of course, you can configure the left-hand side to a path of your choice or use a managed volume instead. See: Volumes | Docker Docs

1 Like

Thank you very much :slight_smile:

So for backups, i can simply use the left path and back it up (and restore it to the path). This would be alot easier then doing stuff like mysql dump. It took me ages to figure out, how to use mysql dump if mysql is also a docker container :melting_face:

Just make sure your container is not running when you create a backup of the host path. Otherwise, you might back up an inconsistent state, which btw. does not happen with mysql dump.

1 Like

Alright, got it. Thank you alot :handshake: