Run Docker on Ubuntu on Windows Subsystem for Linux

Andrés Cuadros picture Andrés Cuadros · Dec 28, 2017 · Viewed 22.3k times · Source

I've tried to run Docker on WSL unsuccessfully. I've installed Docker on WSL following the steps given to install Docker on Ubuntu but when I execute docker ps I get the following error:

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

Watching docker logs I found this:

level=warning msg="Running modprobe nf_nat failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.0-43-Microsoft/modules.dep.bin'\nmodprobe: WARNING: Module nf_nat not found in directory /lib/modules/4.4.0-43-Microsoft`, error: exit status 1"
time="2017-12-28T12:07:23.227671600+01:00" level=warning msg="Running modprobe xt_conntrack failed with message: `modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.4.0-43-Microsoft/modules.dep.bin'\nmodprobe: WARNING: Module xt_conntrack not found in directory /lib/modules/4.4.0-43-Microsoft`, error: exit status 1"
Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.0: can't initialize iptables table `nat': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
 (exit status 3)

Any idea how can I run Docker on WSL?

Answer

Andrés Cuadros picture Andrés Cuadros · Dec 28, 2017

Finally, I could run Docker on WSL in an easy way: You need first to install and run Docker Engine on Windows and then just create a symbolic link on Ubuntu bash pointing to the Windows executable:

sudo ln -s /mnt/c/Program\ Files/Docker/Docker/resources/bin/docker.exe /usr/bin/docker

This link works because from version Windows 10 Creators Update it's possible to run Windows executables from Bash. If your Windows version is previous to Windows 10 Creators Update you can try the solution explained in this blog