Learning Docker
Learning Docker

Reputation: 613

What is the docker.sock equivalent on Windows 10?

I have an application that utilizes docker client to connect to docker daemon. I run this application from inside a container. To that end, I am running my container with following command on both Ubuntu and MacOS:

docker run -d -v /var/run/docker.sock:/var/run/docker.sock someimage

Recently, on my Windows machine I installed Docker for Windows and there is no

/var/run/docker.sock

file. I am unable to figure out what is the equivalent for docker.sock file on Windows.

Update: I found an equivalent of docker.sock on Windows on [docker's repository](https://github.com/docker/docker/search?utf8=%E2%9C%93&q=DefaultDockerHost ) but still I don't know how to map the volume using:

npipe:////./pipe/docker_engine** path

Upvotes: 3

Views: 4613

Answers (2)

Ivan
Ivan

Reputation: 9705

Are you are trying to run Windows containers on Windows host (and not Linux containers on Windows host via Moby VM)? In this case you can't share named pipe (npipe:////./pipe/docker_engine) as docker volume.

It seems the only option is to use TCP sockets. Here is how I've done it In PowerShell:

# Open firewall
# TODO: allow access only from internal nat-ed containers
netsh advfirewall firewall add rule name="Docker daemon " dir=in action=allow protocol=TCP localport=2375

# Find gateway ip address for internal docker nat network, set DOCKER_HOST based on it
$gatewayIpAddress = (docker network inspect nat | ConvertFrom-Json).IPAM.Config[0].Gateway
$dockerHost = "tcp://${gatewayIpAddress}:2375"
$Env:DOCKER_HOST = $dockerHost
[Environment]::SetEnvironmentVariable("DOCKER_HOST", $dockerHost, "Machine")

# Reconfigure docker daemon to use TCP
'{ "hosts": ["' + $dockerHost + '"] }' | Set-Content 'C:\ProgramData\docker\config\daemon.json'

Restart-Service docker

# Smoke Test
docker version

Potentially you can get away with simpler approach instead of finding out gateway IP above, just use COMPUTERNAME. This will mean a bit more network traffic when starting nested container as it will need to access DNS to resolve it to the IP address which would normally be main IP address of the host, not the docker nat gateway IP. Also it will be less secure as Docker daemon will be listening on the external IP of the host, so will be accessible from outside.

Then you can start a container and just pass env var DOCKER_HOST:

docker run -it -e DOCKER_HOST ... 

Above is based on: https://learn.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/deploy-containers-on-nano#manage-docker-on-nano-server

Upvotes: 4

M. Dicon
M. Dicon

Reputation: 41

The first /var/run/docker.sock refers to the same path in your boot2docker virtual machine. Correcly write /var/run/docker.sock

Upvotes: 1

Related Questions