Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run Docker on Ubuntu on Windows Subsystem for Linux

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?

like image 970
Andrés Cuadros Avatar asked Dec 28 '17 13:12

Andrés Cuadros


People also ask

Can Windows Subsystem for Linux run Docker?

We recommend using Docker Desktop due to it's integration with Windows and Windows Subsystem for Linux. However, while Docker Desktop supports running both Linux and Windows containers, you can not run both simultaneously.

Is Docker in WSL2 free?

The Docker engine is free. So the license update won't be any problem for your development and production environment. Portainer is a production-ready software to manage your Docker environment that also often is used in a server cluster environment.

Can Docker run Ubuntu on Windows?

Overview. It is now possible to run Docker containers on Windows 10 and Windows Server, leveraging Ubuntu as a hosting base. Imagine running your own Linux applications on Windows, using a Linux distribution you are comfortable with: Ubuntu!

Can we run Docker without Docker Desktop?

Docker Desktop is Docker (the company)'s first wedge into getting you to run proprietary software, so Docker strongly guides you to download it as the only way to get started: In fact, new users can go pretty far without even realizing that you don't need Docker Desktop to run the Docker daemon.


1 Answers

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

like image 192
Andrés Cuadros Avatar answered Sep 20 '22 11:09

Andrés Cuadros