Docker Community Forums

Share and learn in the Docker community.

Can't mount /user/bin/docker to container

(Vitaly Velikodnyy) #1

Hello everyone!

I have app needed to run docker containers, so I run it with next command:

docker run -p xxxx:xxxx --restart=always --net=xxxx -e HOST=xxxx -v /Applications/ -v /var/run/docker.sock:/var/run/docker.sock --name xxxx -d xxxx/xxxx

Expected behavior

I expect binary file inside docker contaner, like for /var/run/docker.sock file:
docker exec NAME ls -l /var/run/docker.sock
srw-rw---- 1 root staff 0 Jun 10 10:54 /var/run/docker.sock

Actual behavior

But it mounts as directory:
docker exec NAME ls -l /usr/bin/docker
total 0


Your unique id is: 4A602CA6-48B2-4221-BFE3-BA72FFB624C6

  • the output of:
    • pinata diagnose -u on OSX
    • DockerDebugInfo.ps1 using Powershell on Windows
  • a reproducible case if this is a bug, Dockerfiles FTW
  • page URL if this is a docs issue or the name of a man page
  • host distribution and version ( OSX 10.10.x, OSX 10.11.x, Windows, etc )

Steps to reproduce the behavior

  1. Install new docker for osx
  2. run container with mounting of docker bin
    docker run -p xxxx:xxxx --restart=always --net=xxxx -e HOST=xxxx -v /Applications/ -v /var/run/docker.sock:/var/run/docker.sock --name xxxx -d xxxx/xxxx

3.then check docker exec NAME ls -l /usr/bin/docker


(David Maze) #2

You will have two problems with this. The first is that the xhyve VM doesn’t automatically publish /Applications, so if you wanted to try this you should put -v /Mac/Applications/.... But, even if you succeed in that, that will be a Mac Docker binary that you’re trying to run on a Linux container under a Linux container, and it won’t work.

For a couple of similar reasons, even on my Linux hosts, if I’ve needed to invoke Docker from inside a container, I’ve used the container’s distribution’s native tools to install Docker, rather than trying to borrow the host’s binary.

(Vitaly Velikodnyy) #3

Thanks, David! I will try it.

(Djui) #4

Asides @dmaze’s point, it’s easy to install a matching docker binary into your container image. See: