Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Docker running within WSL or connecting back to Windows?

After successfully installing Docker in WSL, if I run standard Docker commands, I get connection errors. Runing with sudo or not yields the same result in all examples.

root@SUR002731165154:~# sudo docker info
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

root@SUR002731165154:~# sudo docker version
Client:
Version:      1.13.1
API version:  1.26
Go version:   go1.7.5
Git commit:   092cba3
Built:        Wed Feb  8 06:42:29 2017
OS/Arch:      linux/amd64
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

However, if I add -H localhost:2375 to the command I can run Docker no problem. Is Docker connecting to my localhost Windows 10 machine or is it running locally on WSL, or is doing a bit of both?

root@SUR002731165154:~# docker -H localhost:2375 version
Client:
Version:      1.13.1
API version:  1.26
Go version:   go1.7.5
Git commit:   092cba3
Built:        Wed Feb  8 06:42:29 2017
OS/Arch:      linux/amd64

Server:
Version:      1.13.1
API version:  1.26 (minimum version 1.12)
Go version:   go1.7.5
Git commit:   092cba3
Built:        Wed Feb  8 08:47:51 2017
OS/Arch:      linux/amd64
Experimental: true

root@SUR002731165154:~# docker -H localhost:2375 info
Containers: 11
Running: 0
Paused: 0
Stopped: 11
Images: 8
Server Version: 1.13.1
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1
runc version: 9df8b306d01f59d3a8029be411de015b7304dd8f
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.8-moby
Operating System: Alpine Linux v3.5
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934 GiB
Name: moby
ID: 4LYM:R5T5:6CPZ:Z2KC:YQ4R:NGN4:V6SR:DF7E:YPYO:7FHY:EQW5:2T7W
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 13
Goroutines: 21
System Time: 2017-02-28T18:54:13.7726687Z
EventsListeners: 0
Registry: https://index.docker.io/v1/
Experimental: true
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
like image 959
Steve Ermish Avatar asked Feb 28 '17 19:02

Steve Ermish


People also ask

How can I tell if Docker is running in WSL?

To check if you have Docker installed, run command docker ps or docker info on a terminal screen to verify it is installed and running.

Does Docker require WSL on Windows?

The docker CLI and UI all work fine from Windows without any additional Linux distros. However for the best developer experience, we recommend installing at least one additional distro and enabling Docker support by: Ensure the distribution runs in WSL 2 mode. WSL can run distributions in both v1 or v2 mode.

Is Docker daemon running WSL?

While the Docker daemon cannot run directly on WSL, you can use the Docker CLI to connect to a remote Docker daemon running through Docker for Windows or any other VM you create (this article covers both methods).

Does Docker run on Windows or Linux?

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.


1 Answers

The Docker daemon can't run under WSL as it doesn't implement the necessary kernel ABI's. If you're running Docker for Windows, you are probably connecting to the Hyper-V virtual machine that it manages.

Because it's on a different machine, you will not be able to mount WSL directories as Docker volumes, but you can build images from a WSL directory. This is because on a build, the client creates a tarball and sends it to the daemon.

like image 80
DeltaWhy Avatar answered Sep 28 '22 07:09

DeltaWhy