I am running a Ubuntu container on Ubuntu VM. I notice when I login to it without any bind mount I see, apart from overlays, /dev/sda1 ( root OR /) from host mounted as /etc/hosts file.
With bind mount I do see the path mapped to a dir inside container but still mount -t ext4 continues to show /dev/sda1.
- My questions
-
Why do I see root ("/") OR /dev/sda1 of host inside a container against /etc/hosts or /etc/resolve.conf or /etc/hostname ?
-
If I bind mount a host dir path inside a container, I see /dev/sda1 now under the “bind mount” path inside container, while I still see other mounts with mount -t ext4
Its confusing me, Why Is it this way? -
Am I limited by the space available on the host, while using the bind mount path inside the container?
Any links to documents/code is welcome along with answers.
Appreciate your time and help.
Thanks
Logs.
- Setup
- Docker build -, running on Ubuntu 19.04 VM inside Virtulbox, running on Windows 10.
-Docker version - 18.09.5
- When I start a new docker container, I see following o/p for df -h
pkondekar@DevVM:~$ docker run -it --rm ubuntu
root@8d8830a07438:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 20G 11G 8.1G 57% /
tmpfs 64M 0 64M 0% /dev
tmpfs 996M 0 996M 0% /sys/fs/cgroup
/dev/sda1 20G 11G 8.1G 57% /etc/hosts
shm 64M 0 64M 0% /dev/shm
tmpfs 996M 0 996M 0% /proc/asound
tmpfs 996M 0 996M 0% /proc/acpi
tmpfs 996M 0 996M 0% /proc/scsi
tmpfs 996M 0 996M 0% /sys/firmware
- mount -t overlays
root@8d8830a07438:/# mount -t overlay
overlay on / type overlay (rw,relatime,lowerdir=/var/lib/docker/overlay2/l/QBA5RAPJND6FWJ5J2NPPB54JEJ:/var/lib/docker/overlay2/l/VX6A55NBSFSMU4I34JOBXXZFWC:/var/lib/docker/overlay2/l/6EIHPYRMBKOEBLGLZECSODUTY7:/var/lib/docker/overlay2/l/G4DAUQTICPYPRW6SXYTYPWV4FG:/var/lib/docker/overlay2/l/4AE4GUZTLOKJXWMXEP24YTGXU2,upperdir=/var/lib/docker/overlay2/c5d0361e5d90def88f2371ad43be2f629db9ef42caf24603520e54b251166d8e/diff,workdir=/var/lib/docker/overlay2/c5d0361e5d90def88f2371ad43be2f629db9ef42caf24603520e54b251166d8e/work,xino=off)
root@8d8830a07438:/#
- mount -t ext4
root@8d8830a07438:/# mount -t ext4
/dev/sda1 on /etc/resolv.conf type ext4 (rw,relatime,errors=remount-ro)
/dev/sda1 on /etc/hostname type ext4 (rw,relatime,errors=remount-ro)
/dev/sda1 on /etc/hosts type ext4 (rw,relatime,errors=remount-ro)
root@8d8830a07438:/
- No bind mounts
pkondekar@DevVM:~$ docker inspect -f "{{ .Mounts }}" 8d88
[]
pkondekar@DevVM:~$
pkondekar@DevVM:~$ docker run -it --rm -v /var:/tmp ubuntu
root@b81ad5fb5523:/# df -h
Filesystem Size Used Avail Use% Mounted on
overlay 20G 11G 8.1G 57% /
tmpfs 64M 0 64M 0% /dev
tmpfs 996M 0 996M 0% /sys/fs/cgroup
/dev/sda1 20G 11G 8.1G 57% /tmp
shm 64M 0 64M 0% /dev/shm
tmpfs 996M 0 996M 0% /proc/asound
tmpfs 996M 0 996M 0% /proc/acpi
tmpfs 996M 0 996M 0% /proc/scsi
tmpfs 996M 0 996M 0% /sys/firmware
root@b81ad5fb5523:/#
root@b81ad5fb5523:/# mount -t ext4
/dev/sda1 on /tmp type ext4 (rw,relatime,errors=remount-ro)
/dev/sda1 on /etc/resolv.conf type ext4 (rw,relatime,errors=remount-ro)
/dev/sda1 on /etc/hostname type ext4 (rw,relatime,errors=remount-ro)
/dev/sda1 on /etc/hosts type ext4 (rw,relatime,errors=remount-ro)
root@b81ad5fb5523:/#