I am starting up a new Gitlab container, and I thought I understood how to use a volume with a bind mount to an existing directory on the host computer, but I’m having trouble figuring out where my files are actually going, because it’s not in the directory I thought I bound to.
- Image:
gitlab/gitlab-ce
, latest (eb7f8158e9e3) - Docker Desktop 4.45.0
- Ubuntu 22.04.5 LTS
Steps to reproduce
Set up in ~/docker/gitlab
:
.env
GITLAB_HOME='/srv/gitlab'
Excerpt from docker-compose.yaml
services: gitlab: [...] volumes: - '$GITLAB_HOME/config:/etc/gitlab:rw' - '$GITLAB_HOME/logs:/var/log/gitlab:rw' - '$GITLAB_HOME/data:/var/opt/gitlab:rw' [...]
The directory /srv/gitlab
was created manually before I started the container, but it was empty, and I was letting docker create the subdirectories.
I ran:
docker compose up -d
and got an error related to file permissions. After a bit of research, I realized that locations outside of the /home
directory needed to be shared explicitly. So in Docker Desktop > Settings > Resources > File Sharing, under Virtual file shares, I added /srv/github
, and ran the same up
command again. This time, it worked, but docker does not seem to be actually putting the shared volume data into the bound directories, as I would expect. If I look in the host system, there is nothing inside of /srv/gitlab
at all.
If I inspect the running container, I see
"Mounts": { { "Type": "bind", "Source": "/srv/gitlab/data", "Destination": "/var/opt/gitlab", "Mode": "rw", "RW": "true", "propagation": "rprivate" },
…and so on for the other shares, so the definition looks like I would expect, binding to the correct host directory. But again, if I look on the host, there’s nothing there.
What’s more worrying is, after setting up gitlab with some users and some sample data, I ran into an error where it seemed I needed to restart gitlab, and ran
docker restart gitlab
…and when it game back up, it seems as if it has started from scratch, as if it were a new container? Which, of course, is a little worrying if my data is not persisting.
Where is it actually putting my files? And why was my data not persisting?