docker/docker — pull request #7781 by cpuguy83 (2014-08-28 14:36:50+00:00)
Title: Remove volumes after build

Since these volumes are both unreferencable, and should be completely
reproducible by subsequent builds, they can be safely removed.

Resolves #6993 which was closed but not dealt with.

In the original implementation we decided that the way `docker rm -v` was traversing the whole container graph to see if any of the containers were referencing the volume being deleted was not ideal, especially when it's called after each build step (or even just at the end of the build).
Instead this is now implemented with a reference counter as well as a volume->container mapping.
Incidentally this is also laying some of the groundwork for first class volumes.