dotcloud/docker — pull request #5369 by a-ba (2014-04-23 22:13:25+00:00)
Title: Added the BINDCONTEXT dockerfile instruction

closes #3056

The `BINDCONTEXT ` instruction arranges for the context to be mounted at the location `` inside the container during the subsequent `RUN` commands.

The context is mounted in read-write mode. This is convenient when building something from sources located in the context since only files that are explicitly installed will persist in the image. Everything else (sources, intermediate files,...) is wiped out when the build is over.

The command is also useful when dealing with a voluminous files. Using BINDCONTEXT instead of ADD avoid making extra copies of temporary files and avoids keeping them in the final image. Depending on the case, this can mitigate #2224 and #332.

There are two outstanding questions:
1. the command mounts *directly* the context directory and let the user modify it (and possibly mess up with next dockerfile commands). An alternatives would be to write changes in an aufs layer to leave the server context intact, but this adds a dependency on aufs (and I wondef if this is really necessary).

2. the stays in the image after the build and is listed in the 'Volumes' section of the image config. Ideally I would prefer removing it from the config and from the filesystem (if it did not exist prior to the mount). I am not very familiay with the runtime API, is there a way to do that cleanly before the commit ?