Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

docker - start failed because /etc/fstab not found

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?

like image 634
qwang07 Avatar asked Mar 21 '18 03:03

qwang07


3 Answers

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
like image 106
Adam Wise Avatar answered Oct 10 '22 19:10

Adam Wise


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

like image 35
MocXi Avatar answered Oct 10 '22 18:10

MocXi


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

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

like image 24
Alex Lopes Avatar answered Oct 10 '22 18:10

Alex Lopes