[Solved] Docker does not start on clean image on RaspberryPi3

I have a Raspberry Pi 3 Model B where I just have put a clean install of DietPi. The system updates to v.6.17.12 and then I install only the Docker software via the Optimized software (#162 on the software list).

However, I can see this fails to start when the system reboots. This is confirmed also when I try to run a container:

root@livingroom:~/docker-transmission-openvpn# docker build -t transmission-openvpn -f Dockerfile.armhf .
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

The “systemctl status docker -l” returns this message:

root@livingroom:~# systemctl status docker -l
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sat 2018-11-10 12:08:47 CET; 10min ago
     Docs: https://docs.docker.com
  Process: 1166 ExecStart=/usr/bin/dockerd -g /mnt/dietpi_userdata/docker-data -H fd:// (code=exited, status=
1/FAILURE)
 Main PID: 1166 (code=exited, status=1/FAILURE)
      CPU: 297ms

Nov 10 12:08:45 livingroom systemd[1]: docker.service: Unit entered failed state.
Nov 10 12:08:45 livingroom systemd[1]: docker.service: Failed with result 'exit-code'.
Nov 10 12:08:47 livingroom systemd[1]: docker.service: Service hold-off time over, scheduling restart.
Nov 10 12:08:47 livingroom systemd[1]: Stopped Docker Application Container Engine.
Nov 10 12:08:47 livingroom systemd[1]: docker.service: Start request repeated too quickly.
Nov 10 12:08:47 livingroom systemd[1]: Failed to start Docker Application Container Engine.
Nov 10 12:08:47 livingroom systemd[1]: docker.service: Unit entered failed state.
Nov 10 12:08:47 livingroom systemd[1]: docker.service: Failed with result 'exit-code'.
root@livingroom:~#

Do you have an idea why this happens and if it can be fixed?

edit: /lib/systemd/system/docker.service

replace
ExecStart=/usr/bin/dockerd -g /mnt/dietpi_userdata/docker-data -H fd://
with
ExecStart=/usr/bin/dockerd -g /mnt/dietpi_userdata/docker-data -H unix://

Thank you mspieth. Actually I solved the issue by starting from a new fresh DietPi installation and installed Docker from the command:

curl -sSL > https://get.docker.com > | sh

Do you know if this bug on the Docker optimized software from DietPi will be fixed?

It works for you now because dietpi-software is the problem not the actual docker install. In /DietPi/dietpi/dietpi-software there is a line:

Set container(s) locations in /lib/systemd/system/docker.service

sed -i “/ExecStart=/usr/bin/dockerd/c\ExecStart=/usr/bin/dockerd -g $G_FP_DIETPI_USERDATA/docker-data -H fd://” /lib/systemd/system/docker.service

This line breaks docker startup. I’ll post a bug report on github.

Thanks mspieth, I had figured out that the problem was in the dietpi-software. I am happy now because in the end I managed but I hope they can fix it so next time I can install docker from the optimized software.

I submitted a bug report for this issue.

Nice to read this.
Just wanted to install docker.
Do you write here when it is repaired or how to fix it?

Until the bug is fixed within dietpi, it’s easy to fix on your own.

  1. Install docker #162 normally via dietpi-software.
  2. At the end of the install, docker will fail to start, thats ok for now.
  3. nano /lib/systemd/system/docker.service
  4. Find the line that says: ExecStart=/usr/bin/dockerd -g /mnt/dietpi_userdata/docker-data -H fd://
  5. Either delete that line or comment it out by adding a # in front of the line.
  6. Add the following line just below the original line: ExecStart=/usr/bin/dockerd -g /mnt/dietpi_userdata/docker-data -H unix://
  7. Save the file
  8. service docker start

That’s it.
You could also just edit the above mentioned file and replace the fd:// with unix://

Perfect.
I will try and report.
Thanks.

EDIT:
I had to “systemctl daemon-reload” before i could start the docker service but now it runs.
Thanks a lot one more time!

Sorry…

Forgot about that… Yes you have to reload systemd or it won’t know you changed the file.

Thanks for report and solution.
Will be fixed with next release :slight_smile:.

To me it still does not work by doing in this way with a fresh new installation of DietPi. Even if I give “systemctl daemon-reload” and then “service docker start” or in the opposite order.

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

My “/lib/systemd/system/docker.service”

...
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -g /mnt/dietpi_userdata/docker-data -H unix://
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always
...

Did you do:
systemctl daemon-reload
before restarting the service? At best do this via:
systemctl restart docker

MichaIng Yes, I had already done that as I wrote in my previous message but I did it again now after rebooting the raspberry pi. Still Docker does not work.

root@router:~# nano /lib/systemd/system/docker.service
root@router:~# systemctl daemon-reload
root@router:~# systemctl restart docker
Job for docker.service canceled.
root@router:~# systemctl status docker.service
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; disabled; vendor preset: enabled)
   Active: failed (Result: core-dump) since Sun 2018-11-18 20:48:51 CET; 6s ago
     Docs: https://docs.docker.com
  Process: 9258 ExecStart=/usr/bin/dockerd -g /mnt/dietpi_userdata/docker-data -H unix:// (code=dumped, signal=SEGV)
 Main PID: 9258 (code=dumped, signal=SEGV)
      CPU: 625ms

Nov 18 20:48:48 router systemd[1]: Starting Docker Application Container Engine...
Nov 18 20:48:51 router systemd[1]: docker.service: Main process exited, code=dumped, status=11/SEGV
Nov 18 20:48:51 router systemd[1]: Stopped Docker Application Container Engine.
Nov 18 20:48:51 router systemd[1]: docker.service: Unit entered failed state.
Nov 18 20:48:51 router systemd[1]: docker.service: Failed with result 'core-dump'.
root@router:~#

docker.service: Main process exited, code=dumped, status=11/SEGV

Okay so there is anther issue then. Please check docker logs for more details.

Sorry I am very newbie to Docker. May I ask what should I do exactly?

Found this post because I’m struggling to get docker running under dietpi on my RPi3 as well.

So under systemd the command to run is:

journalctl -fu docker.service

For me, on my system, where dockerd is failing to start this doesn’t really give me anything useful:

root@pi-hole:~# journalctl -fu docker.service
-- Logs begin at Thu 2016-11-03 17:16:44 GMT. --
Nov 23 22:20:08 pi-hole systemd[1]: Starting Docker Application Container Engine...
Nov 23 22:20:12 pi-hole systemd[1]: docker.service: Main process exited, code=dumped, status=11/SEGV
Nov 23 22:20:12 pi-hole systemd[1]: Stopped Docker Application Container Engine.
Nov 23 22:20:12 pi-hole systemd[1]: docker.service: Unit entered failed state.
Nov 23 22:20:12 pi-hole systemd[1]: docker.service: Failed with result 'core-dump'.
Nov 23 22:20:27 pi-hole systemd[1]: Starting Docker Application Container Engine...
Nov 23 22:20:31 pi-hole systemd[1]: docker.service: Main process exited, code=dumped, status=11/SEGV
Nov 23 22:20:31 pi-hole systemd[1]: Stopped Docker Application Container Engine.
Nov 23 22:20:31 pi-hole systemd[1]: docker.service: Unit entered failed state.
Nov 23 22:20:31 pi-hole systemd[1]: docker.service: Failed with result 'core-dump'.

I have no core dumps in /var/lib/systemd/coredump/ on my host. I also seem to be missing systemd-coredumpctl or coredumpctl…

Did you do the systemd unit change as mentioned above:

sed -i 's|fd://|unix://|' /lib/systemd/system/docker.service
systemctl daemon-reload
systemctl restart docker

Yup.

root@pi-hole:~# cat /lib/systemd/system/docker.service | grep ExecStart
ExecStart=/usr/bin/dockerd -g /mnt/dietpi_userdata/docker-data -H unix://

Also made certain /mnt/dietpi_userdata/docker-data existed and had suitable permissions on it.

MichaIng it has already been mentioned several times that what you wrote was tried.

Anyways, I found out that the problem is apparently in the latest version of docker for rapsberry pi(arm). I realized the problem was this after I still got it not working by installing it on a new diet pi installation but with the docker official script.

Thus, in order to make it working for the moment these are the steps I did:
Install dietpi image
Run docker install script
Run sudo apt-get install docker-ce=18.06.1~ce~3-0~raspbian

The last step downgrades installs the previous version of docker.
Source: docker-ce segmentation fault on Raspbian (v18.09.03) · Issue #38175 · moby/moby · GitHub