Reputation: 71
I'm tring to play with bind mounting and i encourred in a strange behavior, i understand that bind mounting mount a host's folder in the container file system obscuring the original container content. Now when i try to do for examle:
docker run -it -v /home/user:/tmp ubuntu bash
in the /tmp folder of contaner there is the user's home but when i try to bind a "not home folder" like /var/lib:
docker run -it -v /var/lib:/tmp ubuntu bash
the /tmp folder inside a container is empty, why this appen? Moreover if i do inside at the last container for example "touch foo" and i run another container with the same binding:
docker run -it -v /var/lib:/tmp ubuntu bash
I'll find the foo file inside /tmp folder
additional info: i run a ubuntu 19 server inside a VMaware virtual machine
Upvotes: 2
Views: 591
Reputation: 11
I'm writing this answer as the second solution. I uninstalled both snap and apt versions on the default Ubuntu server install, rebooted, then used the docker install scripts from here:
curl -fsSL https://get.docker.com -o get-docker.sh
I can now see my bind mounts inside the container. Not sure of the root cause but this fixed my issue. When I installed Ubuntu server, I selected it to install docker. Maybe this isn't the best idea for fully functioning bind mounts.
Upvotes: 1
Reputation: 71
i found a "dirty" solution, i had previoussly installed docker via snap, i reinstalled docker via apt and now work fine, this will remain a minstery
Upvotes: 4