Missing sub-folders and files from the mount point

I am trying to persist the entire configuration folder of an application on the host system but I noticed that only partial content is written. I cannot locate some of the files under the /var/lib/docker/volumes/ folder. Following is the command I run:

# docker volume create etcsalt
# docker run --name salt --hostname salt -p 4505-4506:4505-4506 -p 8000:8000 -e SALT_SHARED_SECRET=mysecretpassword --ulimit nofile=90000:90000 --mount source=etcsalt,target=/etc/salt -d saltstack/salt:3004.2

I think the following link shows the Dockerfile for the project:

Once the container starts, I check the content of the volume:

root@test:/var/lib/docker/volumes/etcsalt/_data# ls
master.d  minion.d  pki  proxy.d

master.d folder has a couple of files I am looking. The rest of the folders are blank. This is not the case when I check the same folders inside the container.

Can someone provide me some direction here.

Thanks,

I just noticed that when I create a different mount point for each subfolder and run the docker with multiple mount points, I see the files I am looking. I can stop and remove the active docker container and start a new one and everything works as expected.

docker volume create etcsalt-master.d
docker volume create etcsalt-minion.d
docker volume create etcsalt-pki
docker volume create etcsalt-proxy.d

docker run --name salt --hostname salt -p 4505-4506:4505-4506 -p 8000:8000 -e SALT_SHARED_SECRET=mysecretpassword --ulimit nofile=90000:90000 \
--mount source=etcsalt-master.d,target=/etc/salt/master.d \
--mount source=etcsalt-minion.d,target=/etc/salt/minion.d \
--mount source=etcsalt-pki,target=/etc/salt/pki \
--mount source=etcsalt-proxy.d,target=/etc/salt/proxy.d \
-d saltstack/salt:3004.2

What could be the reason for this kind of behavior?

If you look into the Dockerfile you linked, you cans ee this line:

VOLUME /etc/salt/pki/

You mounted /etc/salt and I guess the volume defined in the Dockerfile was mounted over it. Since you haven’t defined any volume with the same destination path (the path after the VOLUME instruction in Dockerfile) Docker created an anonymous volume ( its name is a hash ) so the content of the “pki” folder was saved there.

I don’t know about the rest of the folders. I guess those folders were empty even when you mounted multiple volumes.

This is why I don’t like to use the VOLUME instruction in the Dockerfile as you can’t undo it.

1 Like

Thank you. I don’t want to mess with the official dockerfile of the project. I think I will work around it and define more specific mount points.