WSL icon indicating copy to clipboard operation
WSL copied to clipboard

Running docker on Ubuntu 18.04.2 LTS (WSL Enabled)

Open Kundan22 opened this issue 7 years ago • 25 comments

Copied from Issue#468

tried running sudo /etc/init.d/docker start, it shows [Ok] but after that docker run command returns following

Please suggest

~$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        7 months ago        1.84kB
~$ sudo docker run hello-world
docker: Error response from daemon: OCI runtime create failed: container_linux.go:345: starting container process caused "process_linux.go:303: getting the final child's pid from pipe caused \"EOF\"": unknown.
ERRO[0002] error waiting for container: context canceled

Kundan22 avatar Aug 07 '19 18:08 Kundan22

Can you run wsl.exe -l -v and share the output? I suspect you're using the version 1.0 of WSL which does not work out of the box with Docker. You should see something like this.

PS C:\Users\jbouchard> wsl.exe -l -v
  NAME      STATE           VERSION
* Ubuntu    Running         2

Drakota avatar Aug 07 '19 19:08 Drakota

wsl.exe -l -v doesn't run on my terminal. it just shows how to run run command with options

but following command gives

$ wsl.exe --list 

Windows Subsystem for Linux Distributions:
Ubuntu-18.04 (Default)

Kundan22 avatar Aug 07 '19 20:08 Kundan22

Can you press Win Key + R, write winver and share a screenshot?

Drakota avatar Aug 07 '19 20:08 Drakota

image

is there any other way to check if which version WSL2 or WSL1 is installed?

Kundan22 avatar Aug 07 '19 21:08 Kundan22

~$ sudo /etc/init.d/docker start
[sudo] password for user:
 * Starting Docker: docker                                                             [ OK ]
~$

when I ran the above command it shows [ OK ] but then

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

Kundan22 avatar Aug 07 '19 21:08 Kundan22

I'd suggest you install the Insider Preview build of Windows and follow this tutorial https://docs.microsoft.com/en-us/windows/wsl/wsl2-install

Drakota avatar Aug 07 '19 23:08 Drakota

I tried on 3 different machines but every time I got the same result. on all machine wsl.exe -l -v doesn't return anything.. something is not correct.

Kundan22 avatar Aug 08 '19 07:08 Kundan22

Please note that you'll need to be running Windows 10 build 18917 or higher to use WSL 2

Have you done this step? Follow the procedure to enroll in the Windows Insider Program and select the "Fast" ring updates. image image

Drakota avatar Aug 08 '19 12:08 Drakota

Try build 18932, I am using this one and it works with the same commands you have used.

lucasctd avatar Aug 08 '19 13:08 lucasctd

Alright!!! After following above step getting latest build and wasting 35gb of space...

and running below commands. WSL2 is running docker on ubuntu...

PS wsl --set-default-version 2
For information on key differences with WSL 2 please visit https://aka.ms/wsl2

PS C:\WINDOWS\system32> wsl --set-version Ubuntu-18.04 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
Conversion complete.
PS C:\WINDOWS\system32> wsl -l -v
  NAME            STATE           VERSION
* Ubuntu-18.04    Running         2

Thanks for suggestions @Drakota & @lucasctd @mscraigloewen

Kundan22 avatar Aug 08 '19 21:08 Kundan22

@Kundan22 yw. Keep in mind it may be slow if you access the windows file system as stated in #4387 and #4197

lucasctd avatar Aug 08 '19 21:08 lucasctd

I am downloading build 18956, if WSL2 performance is better on that one, I will post it here.

lucasctd avatar Aug 08 '19 21:08 lucasctd

Closing this issue as the original problem is resolved. Thanks for filing!

craigloewen-msft avatar Aug 08 '19 21:08 craigloewen-msft

After upgrading to 18956 there is windows.old folder (~35 GB). Is it safe to delete it?

Kundan22 avatar Aug 09 '19 09:08 Kundan22

Yes, but you will not be able to rollback to the build you were in case something gets wrong.

lucasctd avatar Aug 09 '19 13:08 lucasctd

Some services like docker (standalone, ubuntu version, installed using bash) does not run even if you use sudo /etc/init.d/docker start or sudo service docker start or /etc/init.d/docker start. I updated from windows 1803 to 1903 (18362.592) today, then tried again, same results.

Then after wasting the whole day, it hits me! What you have to do is, run the linux subsystem as administrator by right clicking from start menu. This will solve the issue and sudo service command will execute as it should, as a sudo user.

abmruman avatar Jan 15 '20 21:01 abmruman

I had similar issue. Now I have working solution for windows 10 home.

  1. install wsl2 (become an insider)
  2. enable wsl2 features
  3. install docker for wsl2
  4. enjoy! You have docker in your linux terminal on wsl2.

https://docs.docker.com/docker-for-windows/wsl-tech-preview/

spanyukov avatar Mar 24 '20 19:03 spanyukov

@spanyukov Unfortunately that requires Microsoft Windows 10 Professional or Enterprise 64-bit.

zoidyzoidzoid avatar Apr 01 '20 17:04 zoidyzoidzoid

@spanyukov Unfortunately that requires Microsoft Windows 10 Professional or Enterprise 64-bit.

@zoidbergwill No, that is the best thing. I have my laptop on Windows 10 Home. Here is my current sys info: Edition: Windows 10 Home Insider Preview Single Language OS Build: 19592.1001

spanyukov avatar Apr 01 '20 19:04 spanyukov

Does anyone know when this will be available for non-insiders? I don't want to join the program just for WSL2...

theAkito avatar Apr 01 '20 19:04 theAkito