"Better" support for volume sharing with sibling containers

Hello Team Docker,

Here’s the problem I have with docker, volumes and sibling containers. Everything is working correctly and fine, and I have a work around https://github.com/client9/dmnt but this hack seems smelly.

Here’s a normal working case:

 docker run --rm --volumes-from=workspace -v ${PWD}:/test -w /test alpine ls -l

# lots of stuff and displays the current directory-- GOOD

I can write lots of scripts and tools that work using this.

But now let’s say, I love docker so much, that I decide to put my dev environment into container itself,

docker run --rm  -it \
                 -v /var/run/docker.sock:/var/run/docker.sock \
                 --volumes-from=workspace \
                 -w /test \
                alpine /bin/sh --login

Cool I’m “in docker” and I passed in the docker.sock so I can create sibling containers, etc. I’m in the /test directory

Now I run my first script

 docker run --rm --volumes-from=workspace -v /test:/test -w /test alpine ls -l


docker on the host doesn’t know it’s being called from within a container, and so everything is relative to the host, not the container, and not the datavolume And /test on the host is nothing. So this is correct, but ugly.

To work around this I wrote https://github.com/client9/dmnt which checks to see if the items listed in ${PWD} (or whatever you put here) is on a data volume? and if so remaps the command line so this works:

docker run --rm \
 -v d5cd7d8a46b907703e623e93ed4d2f7edf9c8cc9c1bdb420c3ad7795b71fec06:/test \
 -w /test  alpine ls -l

So for instance this always the same, even if on host, or if I’m in sibling container.

docker run --rm $(dmnt .) -w ${PWD}  alpine ls -l

But the algorithm dmnt uses to figure out if a path is on the host or on a data volume is not-great and kinda hacky. Ideally I’d like some flag in the cli that resolves the path listed in the ‘-v’ flag and understands that a path is actually on a data volume.

My apologies on terminology, this is awfully confusing to explain. Hopefully you get the idea.

Am I missing anything? Any improvements? Should I file a ticket/feature request at GitHub.com/docker