Sub topic 15
Troubleshooting and removing rootless Docker
This chapter assumes you have installed a rootless daemon, you know how systemd --user works, and you can use DOCKER_HOST or Docker contexts. Most rootless problems come from one of four places: the subordinate ID ranges, the user service, the client connection, or a feature that rootless mode restricts.
A diagnostic order
Check the layers from the bottom up. If a lower layer is broken, the checks above it will also fail.
Setup and daemon failures
If the setup tool reports that newuidmap is missing or that no subordinate IDs exist, repeat the host checks:
grep "^$(whoami):" /etc/subuid /etc/subgid
command -v newuidmap newgidmapNo output from grep means your user has no range. An administrator can add one with usermod, and you then log in again.
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 "$(whoami)"If the ranges exist but the daemon still fails, read its log. The daemon is a user unit, so use --user:
systemctl --user status docker
journalctl --user -u docker --no-pager -n 50If the daemon works while you are logged in but stops after you log out, lingering is not enabled. Run sudo loginctl enable-linger "$(whoami)".
Client and feature problems
The error Cannot connect to the Docker daemon usually means the client is talking to the wrong socket. It often happens in a new shell where DOCKER_HOST is unset. Set it again or select the context:
export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock
docker context use rootless
docker info --format '{{.SecurityOptions}}'The last command should list rootless. If it doesn't, you are still connected to a rootful daemon.
Other common symptoms:
| Symptom | Likely cause | Fix |
|---|---|---|
| `permission denied` publishing port 80 | Unprivileged users cannot bind ports below 1024 | Publish a higher port, or lower `net.ipv4.ip_unprivileged_port_start` |
| `--memory` or `--cpus` ignored, with warnings in `docker info` | cgroup v2 controllers not delegated to your user | Check `cgroup.controllers` and configure systemd delegation |
| Files in bind mounts owned by odd UIDs | Container IDs map to your subordinate range | Expected behavior. Use `chown` from inside a container if needed |
To see the delegated controllers, run:
cat "/sys/fs/cgroup/user.slice/user-$(id -u).slice/user@$(id -u).service/cgroup.controllers"If cpu, memory, and pids are missing, limits cannot be enforced.
Removing rootless Docker
Uninstall in this order so that nothing is left running or orphaned:
- Stop and remove your containers if you want the data gone.
- Run the uninstall step of the setup tool. It removes the systemd user unit and the
rootlessCLI context. - Delete the data directory with
rootlesskit, because plainrmcannot delete files owned by mapped subordinate IDs. - Remove
DOCKER_HOSTfrom your shell profile.
systemctl --user stop docker
dockerd-rootless-setuptool.sh uninstall
rootlesskit rm -rf ~/.local/share/dockerIf you no longer need lingering, run sudo loginctl disable-linger "$(whoami)". You can also remove the /etc/subuid and /etc/subgid entries, but only if no other tool, such as rootless Podman, uses them.
Exercise
After a reboot, docker ps fails with a connection error, but systemctl --user status docker shows the unit as inactive. You had enabled the unit. Which setting did you most likely miss, and which command fixes it?
Show answer
Lingering was not enabled, so the user manager did not start at boot and the daemon never ran without a login session. Run sudo loginctl enable-linger "$(whoami)", then start the daemon with systemctl --user start docker.
Exercise
Why must you delete ~/.local/share/docker with rootlesskit rm -rf instead of rm -rf?
Show answer
The directory contains files owned by subordinate UIDs and GIDs. Your normal user cannot remove them, but rootlesskit runs the command inside the same user namespace, where those IDs are mapped and removable.