Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker for windows equivalent for "-v /var/run/docker.sock:/var/run/docker.sock"

I'm trying to control the host docker service from inside a container.

With Linux host and Linux container that is usually done like this: docker run -it -v /var/run/docker.sock:/var/run/docker.sock alpine

I now want to achieve the same with a Docker for Windows host and a Linux container.

If tried quite a lot of things, mostly using DOCKER_HOST with varying IP's like 10.75.0.1:2375 (IP of docker VM), 172.17.0.1:2375 (container IP) and 0.0.0.0:2375 as well as 192.168.178.xxx:2375 (host IP).

But apparently nothing responds on port 2375 or 2376 which I checked with something like: docker run -ti --rm alpine /bin/sh -c "apk add -U nmap && nmap -Pn 10.72.0.1 -p 2375-2376"

At this point I'd like to know if this is even possible with Docker for Windows. Most information I found concerns docker-machine / VirtualBox combinations.

like image 681
PeterE Avatar asked Mar 21 '17 22:03

PeterE


2 Answers

This works fine when running Linux containers using Docker for Windows too (but not when running Windows containers). Just ensure that your shell won't rewrite paths or similar.

like image 122
friism Avatar answered Oct 24 '22 16:10

friism


I don't know how SO works so if necroposting is frowned upon then sorry. I also don't use docker on windows but this thread came up during my search for setting up portainer. I figured out the thing that I wanted to figure out and on first login portainer gave me this warning:

 Ensure that you have started the Portainer container with the following Docker flag:
-v "/var/run/docker.sock:/var/run/docker.sock" (Linux).
or
-v \\.\pipe\docker_engine:\\.\pipe\docker_engine (Windows).

So, there you go. Hope that helps.

like image 42
Shteef Avatar answered Oct 24 '22 15:10

Shteef