Restart docker daemon in rootless mode (on Linux)

4.2k views Asked by At

How can I restart docker daemon running in rootless mode on Linux?

Stopping it works fine with:

systemctl --user stop docker.service

but starting it back again fails when using:

systemctl --user start docker.service

The command doesn't return anything but when checking the docker info it says:

ERROR: Cannot connect to the Docker daemon at unix:///run/user/1000/docker.sock. Is the docker daemon running?

It doesn't give any further information...

I had this error a couple of times before, when I accidentally run docker with sudo and therefore got mixed up permissions in my data-root (defined in daemon.json). But this time chowning it back to $USER didn't help with the restart. Also restarting the host machine didn't help (as it did a couple of times previously).

1

There are 1 answers

1
FullStack Alex On

Ok, it seems that "userns-remap" is not compatible with rootless mode:

Rootless mode executes the Docker daemon and containers inside a user namespace. This is very similar to userns-remap mode, except that with userns-remap mode, the daemon itself is running with root privileges, whereas in rootless mode, both the daemon and the container are running without root privileges. Rootless mode does not use binaries with SETUID bits or file capabilities, except newuidmap and newgidmap, which are needed to allow multiple UIDs/GIDs to be used in the user namespace.

I was trying to fix permission issues on shared volumes by experimenting with setting UIDs/GIDs and added "userns-remap" to the ~/.config/docker/daemon.json:

{
  "data-root": "/home/me/docker/image-storage",
  "userns-remap": "me"
}

So deleting userns-remap from the config file fixed the restarting issue... Man, docker, at least a hint to the config file would be great... Because the userns-remap option was mentioned on some official docker doc pages I didn't even consider it as the source of the trouble in the first place.