Running docker on Ubuntu 18.04.2 LTS Running docker on Ubuntu 18.04.2 LTS unix unix

Running docker on Ubuntu 18.04.2 LTS


Docker is now supported on WSL2

Pre-requisite for running docker successfully on WSL2

  1. Windows 10 (Build 18932 or higher). To check the OS Build version Win-Key + R, run command "winver"
  2. You can get the Build#18932 by registering for windows insider program and then check latest windows updates on your machine
  3. Enable WSL on your machine( Windows10 ) and then run wsl --set-default-version 2 with admin on Powershell command to always use WSL2 on your machine

Now you are ready to install Linux distro on your machine. Install Ubuntu on Windows 10 WSL using these instructions

you need to start the docker explicitly with sudo /etc/init.d/docker start

To verify everything is fine after installation; run the following command on Powershell. If it shows below output, that means Ubuntu-18.04 is running on WSL 2

PS> wsl -l -v NAME            STATE           VERSION* Ubuntu-18.04    Running         2

-reference: microsoft/wsl on Github


You cant run the docker daemon inside of WSL, which means you cant host containers inside of WSL. But you can connect to the daemon running on windows using the docker client running inside of WSL.

Firstly you need to get docker desktop for windows https://docs.docker.com/docker-for-windows/install/

When you have done this do ensure that the setting to expose daemon on tcp://localhost:2375 without TLS is turned on.

Then install docker in WSL

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"sudo apt-get updatesudo apt-get install docker-ce

And set the env variable so that all docker commands go to the daemon exposed in windows

export DOCKER_HOST=tcp://localhost:2375

You can now enjoy your docker commands in WSL :-)


There are several tweaks and steps you still need to do to get wsl2 working with docker,

Have a look at https://codingfullstack.com/cloud/docker-installation-wsl2/ if you would like to know more about on how to get this working.