-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Inability to use bind mounts if source is on / #37032
Description
- When running a recent version of docker-ce, it is not possible to create a bind mount for a directory which is on / (i.e. a root mount point):
docker run -ti -v /var/lib/kubelet:/dummy:shared,z ubuntu /bin/bash
docker: Error response from daemon: linux mounts: Could not find source mount of /var/lib/kubelet.
- There is a warning on daemon start (reported docker-ce package is missing for Ubuntu "Bionic" 18.04 LTS x86_64 docker/for-linux#290 (comment)):
5月 04 22:49:29 docularxu-Precision-7520 dockerd[9003]: time="2018-05-04T22:49:29.592148011+08:00" level=warning msg="Error while setting daemon root propagation, this is not generally critical but may cause some functionality to not work or fallback to less desirable behavior" dir=/var/lib/docker error="error getting daemon root's parent mount: Could not find source mount of /var/lib/docker"
Workaround
For those suffering from the issue (only Docker CE 18.05 is affected), a quick workaround is to bind mount the directory on the host to itself, i.e. do mount --bind $dir $dir before starting a container. Here's a full example:
# docker run -ti -v /var/lib/kubelet:/dummy:shared,z ubuntu /bin/bash
docker: Error response from daemon: linux mounts: Could not find source mount of /var/lib/kubelet.
# mount --bind /var/lib/kubelet /var/lib/kubelet
# docker run -ti -v /var/lib/kubelet:/dummy:shared,z ubuntu /bin/bash
root@984f30b36d51:/#