Search code examples
dockerdocker-for-windowsdocker-desktop

docker for windows how to access docker daemon from container


Im running Docker Desktop for Windows (hyper V) and I need to access docker daemon from the container via tcp. It is possible to connect to it from the host like: curl -v 127.0.0.1:2375/info but not possible to access it from a container using my host IP address. Maybe someone knows how to do that or at least how to ssh to that docker vm, for example it is possible to ssh in to it on mac by executing: screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty


Solution

  • I've figured how to do that using socat tool which takes docket.socket and proxy TCP calls to it.

    So I've launched container with a socat which mount docker.sock since it is available inside of a VM and expose 2375 port:

    docker run -p 2375:2375 -v /var/run/docker.sock:/var/run/docker.sock codenvy/socat -d -d TCP-L:2375,fork UNIX:/var/run/docker.sock
    

    With that now, I'm able to access docker daemon API through socat container.