Docker Community Forums

Share and learn in the Docker community.

Do not remove Auto-creating missing host paths for bind mounts


(Marcpawl) #1

Instead of removing the Auto-creating missing host paths for bind mounts feature entirely how about having an option that enables it.

I am using it for a very helpful use case for developer builds.

I have a wrapper with setuid permission that starts an image that mounts a developers directory into the image using the UID of the developer, and then starts the build in the developers directory.

The wrapper ensures that the directory is safe to mount.

With this setup a developer gets a compile in the directory they are working on without being root with all the path information preserved. The image cannot know a priori what the layout of the developers disk is, since developers are free to move around on the disk where there are building from.

There are workarounds such as building up an image, for each build but it would slow things down.

example usage:

]$ ~builder/d_x8664/build pwd
Examing arg /home/marcpawl/nightly_builds/r1/nb20160224
source directory: /home/marcpawl/nightly_builds/r1/nb20160224
real source directory: /home/marcpawl/nightly_builds/r1/nb20160224
Current local time and date: Wed Feb 24 15:26:14 2016
Adding run argument /usr/local/bin/mybuild.sh
Adding run argument /home/marcpawl/nightly_builds/r1/nb20160224
/bin/docker run --rm -i -t -u 1001:9999 -v /home/marcpawl/nightly_builds/r1/nb20160224:/home/marcpawl/nightly_builds/r1/nb20160224 -v /home/marcpawl:/home/marcpawl d_x8664 /usr/local/bin/mybuild.sh /home/marcpawl/nightly_builds/r/nb20160224
Current local time and date: Wed Feb 24 15:26:14 2016
/home/marcpawl/nightly_builds/r1/nb20160224/build.sh
and the build is continues inside the container from /home/marcpawl/nightly_builds/r1/nb20160224

This has been really great in letting a developer work as if they are using NFS over multiple machines.

===

Auto-creating missing host paths for bind mounts
Deprecated in Release: v1.9
Target for Removal in Release: 1.11

When creating a container with a bind-mounted volume-- docker run -v /host/path:/container/path – docker was automatically creating the /host/path if it didn’t already exist.

This auto-creation of the host path is deprecated and docker will error out if the path does not exist.