WSL: Docker daemon fails with following output

This bug-tracker is monitored by developers and other technical types. We like detail! So please use this form and tell us, concisely but precisely, what’s up. Please fill out ALL THE FIELDS!

If you have a feature request, please post to the UserVoice. If you’re reporting a BSOD, don’t post here! Instead, e-mail “secure@microsoft.com”, and if possible attach the minidump from "C:\Windows\minidump".

  • Your Windows build number: (Type ver at a Windows Command Prompt)

  • What you’re doing and what’s happening: (Copy&paste specific commands and their output, or include screen shots)

  • What’s wrong / what should be happening instead:

  • Strace of the failing command, if applicable: (If <cmd> is failing, then run strace -o strace.txt -ff <cmd>, and post the strace.txt output here)

See our contributing instructions for assistance.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 15
  • Comments: 91 (1 by maintainers)

Most upvoted comments

Thanks for starting this thread. WSL PM here. As mentioned in the above comment, we have improved Docker support in recent builds of WSL. Most (if not all) versions of docker-ce work with WSL. We’re working on a large set of changes for WSL currently. As part of those changes, we are looking at adding native Docker support in WSL. I will add to this thread and other issues on Docker support when I have additional updates to share

I’m glad to say Docker daemon finally runs on WSL. I’m testing on build 17134.

The most important part is dockerd will only run on an elevated console (run as Admin) and cgroup should be always mounted before running the docker daemon.

The steps to install docker on Ubuntu Xenial are:

sudo apt install docker.io
sudo usermod -aG docker $USER

And every time you need to run the daemon, always on an elevated ubuntu.exe:

sudo cgroupfs-mount
sudo service docker start

After that I tried these and did work:

docker run --rm hello-world

docker run --rm -it alpine sh

docker run -p 8888:8888 --name tensorflow-udacity -it gcr.io/tensorflow/udacity-assignments:1.0.0

It’s important to note that docker version in Xenial repositories is moby 1.13.1 which would be docker-ce 17.02. The last docker-ce version that works right now on build 17134 is 17.09.0. Anything after that fails on extracting the docker images.

Thanks to @targat1982’s post on reddit

That’s great news!

Unfortunately, docker-compose still doesn’t work. I’m getting :

jerry@PC:/mnt/c/Users/jerry/projects/my-project$ docker-compose up -d
Creating network "project_project" with driver "bridge"
ERROR: Failed to Setup IP tables: Unable to enable NAT rule:  (iptables failed: iptables --wait -t nat -I POSTROUTING -s 172.20.0.0/16 ! -o br-9e8373fca539 -j MASQUERADE: iptables: No chain/target/match by that name.
 (exit status 1))

There is a problem with iptables which is not fully supported via WSL yet.

Please upvote here: https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/32025199-support-iptables

Microsoft Windows [Version 10.0.15063]

Within the Bash on Ubuntu on Windows environment I successfuly installed docker.io with apt.

Subsequently I try to activate a docker container following https://github.com/tensorflow/tensorflow/tree/master/tensorflow/examples/udacity

Thereafter I get bash telling me the docker daemon is not running. Trying to run dockerd (the daemon) result in the following output:

INFO[0000] libcontainerd: new containerd process, pid: 124
WARN[0001] Failed to configure golang's threads limit: open /proc/sys/kernel/threads-max: no such file or directory
ERRO[0001] 'overlay' not found as a supported filesystem on this host. Please ensure kernel is new enough and has overlay support loaded.
INFO[0001] Graph migration to content-addressability took 0.00 seconds
WARN[0001] Your kernel does not support cgroup memory limit
WARN[0001] Unable to find cpu cgroup in mounts
WARN[0001] Unable to find blkio cgroup in mounts
WARN[0001] Unable to find cpuset cgroup in mounts
WARN[0001] mountpoint for pids not found
FATA[0001] Error starting daemon: Devices cgroup isn't mounted``

on clean ubuntu 18.04 just run these commands within a privileged bash:

wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_17.09.0~ce-0~ubuntu_amd64.deb -P /tmp/ sudo dpkg -i /tmp/docker-ce_17.09.0~ce-0~ubuntu_amd64.deb sudo apt -y -f install sudo usermod -aG docker $USER sudo apt -y install cgroupfs-mount sudo cgroupfs-mount sudo service docker start

docker run --network host hello-world

seeing the exact same issue as @HanJoHibender, I know it’s not simple, but having docker run like that on windows, is a game changer. it would be amazing. (I don’t have the Pro version on my home computer, and the vm based docker is a pain, and slow)

The most important part is dockerd will only run on an elevated console (run as Admin) and cgroup should be always mounted before running the docker daemon.

Just highlighting this note. I have missed it initially. Ensure your WSL terminal is running on elevated console

Are there any plans to add support for docker to wsl?

Here’s my information if it can be any help.

ver - Microsoft Windows [Version 10.0.15063] strace -o strace.txt -ff service docker start - stacktace /var/log/docker.log

@six7 you can try to run Docker daemon with parameter --iptables=false.

Even better, you should set this parameter in the configuration file /etc/docker/daemon.json like this:

{
  "iptables":false
}

No more docker-compose networking problem 😃

Yes. I ended up adding an SSD to my pc and installing Linux on it. ¯_(ツ)_/¯

wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_17.09.0~ce-0~ubuntu_amd64.deb -P /tmp/
sudo dpkg -i /tmp/docker-ce_17.09.0~ce-0~ubuntu_amd64.deb
sudo apt -y -f install

doesn’t work anymore the -f install will overwrite everything with 18.09 and you will get to the same broken state

I’ve been able to make it work by changing the sequence to:

wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_17.09.0~ce-0~ubuntu_amd64.deb -P /tmp/
sudo dpkg -i /tmp/docker-ce_17.09.0~ce-0~ubuntu_amd64.deb
sudo usermod -aG docker $USER
sudo apt -y install aufs-tools cgroupfs-mount libltdl7
sudo cgroupfs-mount
sudo service docker start

In my own installation, it works everything, including commands without “–network host” option.

Hope this helps.

@onomatopellan Thanks for your help! My issue is now solved!

I got this error :

Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.1: 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)

I tried following this : https://github.com/docker/for-linux/issues/123#issuecomment-346546953 but when I enter the commands using sudo I got this error : RTNETLINK answers: Permission denied

The solution was to run the sudo service docker start inside a bash terminal elevated as admin (windows side)! 👍

EDIT : Too bad my next step was to use docker-compose! 😢 I hit this exact problem : https://github.com/Microsoft/WSL/issues/2291#issuecomment-396570242

@six7 you can try to run Docker daemon with parameter --iptables=false.

We are looking at adding native Docker support in WSL.

This is amazing! The absence of a native Linux docker is the only thing stopping many of us from developing on Windows.

Please also consider supporting docker-compose, which requires iptables from what I read.

@six7 you can try to run Docker daemon with parameter --iptables=false.

Even better, you should set this parameter in the configuration file /etc/docker/daemon.json like this:

{
  "iptables":false
}

No more docker-compose networking problem 😃

perfect,it has sovled the problem that starting docker service with error bellow:

Error starting daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables -t nat -N DOCKER: iptables v1.6.1: 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)

@WSLUser Docker for Windows requires a HyperV VM to run the container and in enterprise environment they generally disable running VMs because of security. So ideally if we can run Docker inside WSL without and need for VM that would be much better.

Hey guys,

thank you for this thread! I’m glad I’m not alone in this! Below my experience so far.

I’m running Windows 10 Pro Version 1903 Build 18362:

PS C:\> (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name ReleaseId).ReleaseId
1903

C:\>ver
Microsoft Windows [Version 10.0.18362.720]

I perfomed a reset of Ubuntu WLS with the following steps:

Right-click on Ubuntu 18.04 LTS (WLS) icon > More > App Settings > Reset

Then I launched Ubuntu WLS and typed these commands as suggested:

sudo apt-get update
wget https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/amd64/docker-ce_17.09.0~ce-0~ubuntu_amd64.deb -P /tmp/
sudo dpkg -i /tmp/docker-ce_17.09.0~ce-0~ubuntu_amd64.deb
sudo apt -y -f install
sudo usermod -aG docker $USER
sudo apt -y install cgroupfs-mount
sudo cgroupfs-mount
sudo service docker start

When I type the last one, I get the following “OK” output:

nw@nw:~$ sudo service docker start
 * Starting Docker: docker                                                                                       [ OK ]

But then running “docker ps” returns the following error:

nw@nw:~$ docker ps
Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get http://%2Fvar%2Frun%2Fdocker.sock/v1.32/containers/json: dial unix /var/run/docker.sock: connect: permission denied

Running Ubuntu WLS as Administrator doesn’t change anything.

If I close Ubuntu WLS and open it again, the error is the one we are discussing in this thread:

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

Any other suggestion to make docker running in Ubuntu WLS for Windows 10, and get rid of Docker Desktop (which it’s a pain when handling data volumes due of permission issues etc)?

We installed Docker Desktop for Windows on my Windows 10 w/ WSL Ubuntu 1804.2019 and still receive the error:

$ docker run --network host hello-world docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. See ‘docker run --help’.

@duke-cliff Were you able to get this working with Windows 10 1909? I followed the same steps + disabling iptables, but I end up with:

Error starting daemon: Error initializing network controller: Error creating default "bridge" network: permission denied

@Knedox’s solution appears to work (for me) up to 18.06.1, but not on anything more recent.

However it appears only to work with networking in ‘host’ mode. Using ‘bridge’ mode (which is the default) gives me an error failed to add interface veth... to sandbox: failed to get link by name. So back to square one unless your containers don’t need to access the outside world AFAICS?

Any news about docker-compose? Is it working on latest builds?

@tara-raj is there any rough timeline for this that you could share? I would like to know whether we are talking about weeks, months or years from now:)

Thanks @onomatopellan . Could you please edit your post, making the part The most important part is dockerd will only run on an elevated console (run as Admin) as bold, or any other way that can be more eye-catching

thanks

@jgoux read carefully the comment https://github.com/Microsoft/WSL/issues/2291#issuecomment-383698720 The last docker-ce version that works right now on WSL is 17.09.0

Hi @onomatopellan, I’m really looking forward to the feature update in September. For now, I followed the install docs and installed that specific docker-ce version:

sudo apt-get install docker-ce=17.09.0~ce-0~ubuntu

You mentioned this earlier:

And every time you need to run the daemon, always on an elevated ubuntu.exe:

sudo cgroupfs-mount
sudo service docker start

I get an error when I run it:

$ sudo /usr/bin/cgroupfs-mount
mount: unknown filesystem type 'cgroup'

I’m a little confused what that means, but I’m googling…

@zz80 As I said earlier in this thread.

It’s important to note that docker version in Xenial repositories is moby 1.13.1 which would be docker-ce 17.02. The last docker-ce version that works right now on build 17134 is 17.09.0. Anything after that fails on extracting the docker images.

Install docker-ce 17.09.0 OR Install latest Windows Insider build OR wait for next feature Update in September.

Build 17723 fixes the high CPU usage problem I had with latest Docker-ce probably because of #3276. Now every docker-ce version out there runs well on WSL and I’d even say in a more stable manner.

Systemd is PID1. Right now WSL uses a closed-source custom init due to that.

@stevefan1999 Are you on build 17134? That problem was due non supported MS_SLAVE flag on mount. It was fixed in build 17666

Running docker from Bionic (docker-ce 17.12.1) on latest insider builds works but containerd-shim shows high CPU usage on idle. Probably some syscall that was stubbed but not implemented yet.

The version of docker you’re using is obsolete. It’s version 1.something. The current version is 17.something. I’m having a problem with ivoke-rc.d though.