Docker Community Forums

Share and learn in the Docker community.

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

build
docker

(Pawanmude) #1

I installed Docker version 17.09.1-ce, build 19e2cf6 on “Windows 10 Enterprise” laptop.

When I use powershell and on powershell command prompt type “docker run hello-world” getting expected output.

When I use “Bash on Ubuntu on Windows” and install Docker version 17.09.1-ce, build 19e2cf6 on Bash; getting error

docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

While searching over net; at couple of places (Ex: https://github.com/Microsoft/WSL/issues/964) it’s mentioned as known issue. Can anyone please confirm; if issue still exits or there is any workaround to resolve above mentioned error.


(Michael Friis) #2

See this post, there’s a relay you can use: https://blogs.technet.microsoft.com/virtualization/2017/12/08/wsl-interoperability-with-docker/


(Pawanmude) #3

@friism ; i’m getting error while “Building the Relay” .

$ go get -d github.com/jstarks/npiperelay
package golang.org/x/sys/windows: fork/exec /usr/bin/git: invalid argument
$


(Ramicon) #5

Found the solution on this post: https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/

Running docker against an engine on a different machine is actually quite easy, as Docker can expose a TCP endpoint which the CLI can attach to.

This TCP endpoint is turned off by default; to activate it, right-click the Docker icon in your taskbar and choose Settings, and tick the box next to “Expose daemon on tcp://localhost:2375 without TLS”.

With that done, all we need to do is instruct the CLI under Bash to connect to the engine running under Windows instead of to the non-existing engine running under Bash, like this:

$ docker -H tcp://0.0.0.0:2375 images

There are two ways to make this permanent – either add an alias for the above command or export an environment variable which instructs Docker where to find the host engine:

$ echo “export DOCKER_HOST=‘tcp://0.0.0.0:2375’” >> ~/.bashrc
$ source ~/.bashrc

Now, running docker commands from Bash works just like they’re supposed to.

$ docker run hello-world
Hello from Docker!This message shows that your installation appears to be working correctly.