14

I'm using Window Linux Subsystem (Debian stretch). Followed the instruction on Docker website, I installed docker-ce, but it cannot start. Here is the info:

$ sudo service docker start
grep: /etc/fstab: No such file or directory
[ ok ] Starting Docker: docker.
$ sudo service docker status
[FAIL] Docker is not running ... failed!

What should I do with /etc/fstab not found?

qwang07
  • 1,136
  • 2
  • 11
  • 20

4 Answers4

14

to fix fstab

touch /etc/fstab

if you run dockerd, it will give you the failed message:

INFO[2022-01-27T17:55:14.100489400+07:00] Loading containers: start.
WARN[2022-01-27T17:55:14.191666800+07:00] Running iptables --wait -t nat -L -n failed with message: `iptables v1.8.2 (nf_tables):  CHAIN_ADD failed (No such file or directory): chain PREROUTING`, error: exit status 4
INFO[2022-01-27T17:55:14.493716300+07:00] stopping event stream following graceful shutdown  error="<nil>" module=libcontainerd namespace=moby
INFO[2022-01-27T17:55:14.494906600+07:00] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
INFO[2022-01-27T17:55:14.495048400+07:00] stopping healthcheck following graceful shutdown  module=libcontainerd
failed to start daemon: Error initializing network controller: error obtaining controller instance: failed to create NAT chain DOCKER: iptables failed: iptables --wait -t nat -N DOCKER: iptables v1.8.2 (nf_tables):  CHAIN_ADD failed (No such file or directory): chain PREROUTING
 (exit status 4)

that is Debian nat issue, fix it with:

sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy

now you can start the service again

you can follow this to make it start on startup https://askubuntu.com/a/1356147/138352

Edited:

if the issue with IP table still persisted try to set WSL version to 2, run the command from Windows shell:

wsl --set-version <distribution name> 2

the distribution list can be found with command wsl -l

MocXi
  • 456
  • 5
  • 14
12

I was getting the same error. Apparently on my install of WSL with Debian, I didn't have an etc/fstab file. Surprisingly, just creating the file via 'touch' worked:

sudo touch /etc/fstab
Adam Wise
  • 2,043
  • 20
  • 17
  • 2
    Not working for me on Wsl2 with Debian 10, but [this](https://stackoverflow.com/a/70877542/1705829) helped. – Timo Mar 05 '22 at 19:16
2

Perhaps a good signal https://learn.microsoft.com/en-us/windows/wsl/release-notes#build-17093

WSL now processes the /etc/fstab file during instance start [GH 2636].

Alex Lopes
  • 21
  • 1
  • 4
-1

For anybody stumbling across this years later like me, Docker doesn't work inside WSL.

But you can use Docker for Windows and WSL2 to run native containers inside your Linux Distro and the install and config is quite painless https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-containers

Alex D
  • 970
  • 6
  • 13
  • Docker works fine inside WSL 2; the link only says you can't do both at the same time (run linux docker inside WSL AND run windows docker) – Mikeb Oct 19 '22 at 12:28
  • Maybe I said WSL instead of WSL 2 because I meant WSL instead WSL 2. – Alex D Oct 19 '22 at 12:40