Sub topic 5
Checking that your host is ready
Rootless Docker depends on a few kernel features, helper programs, and user settings. This chapter assumes you know basic Docker usage, the Linux command line, Linux users and file permissions, and basic systemd. Checking these first is faster than debugging a failed install later.
What the host must provide
Rootless mode puts the daemon in a user namespace, so the host needs the pieces that make that work:
- A range of subordinate UIDs and GIDs assigned to your user, at least 65536 of each.
- The
newuidmapandnewgidmaphelper binaries. They are setuid programs that write the ID mappings for an unprivileged user. On most distributions theuidmappackage provides them. - A kernel that allows unprivileged user namespaces.
- A user running a systemd user session, because the daemon runs as a systemd user service.
For resource limits you also want cgroup v2 with delegated controllers. That is optional for a first install and is covered in a later chapter.
Check subordinate ID ranges
Each user needs a line in /etc/subuid and /etc/subgid. A line has the form user:start:count.
# Check that the current user has subordinate ID ranges
grep "^$(whoami):" /etc/subuid /etc/subgid
# Check that the helper binaries are installed
command -v newuidmap newgidmapA healthy result looks like this:
/etc/subuid:alice:100000:65536
/etc/subgid:alice:100000:65536
/usr/bin/newuidmap
/usr/bin/newgidmapThe count must be 65536 or more. If grep prints nothing, your user has no range. If command -v prints nothing for a helper, it is not installed.
Fix what is missing
Install the helper package. On Debian and Ubuntu:
sudo apt-get install -y uidmapIf the range is missing, an administrator can add one with usermod. Replace alice with your user name. The start value must not overlap any other user's range.
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 aliceOn a host where users come from LDAP or another network directory, /etc/subuid may not be the source of truth. Check how your system resolves subordinate IDs before editing the files.
Check the kernel and session
Some distributions restrict unprivileged user namespaces. Read the relevant setting where it exists:
# Debian-based kernels: 1 means allowed
cat /proc/sys/kernel/unprivileged_userns_clone
# Number of user namespaces allowed; 0 disables them
cat /proc/sys/user/max_user_namespacesThe first file does not exist on every kernel, so a "No such file" error there is not a failure. The second must be greater than 0. Recent Ubuntu releases may also block unprivileged namespaces through AppArmor. If setup fails with a permission error after the other checks pass, look at the Troubleshooting chapter.
Finally, confirm that you are in a real login session with a systemd user manager. Log in directly or over SSH. Using su or sudo -u to switch users often leaves XDG_RUNTIME_DIR unset, and the user service will not work.
echo "$XDG_RUNTIME_DIR"
systemctl --user statusThe first command should print /run/user/<uid>. The second should show a running user manager rather than an error about connecting to the bus.
Exercise
Running grep "^$(whoami):" /etc/subuid /etc/subgid prints nothing, but command -v newuidmap newgidmap prints both paths. Is the host ready for rootless Docker, and what would you do?
Show answer
No. The helpers are installed, but your user has no subordinate UID or GID range. An administrator should add one of at least 65536 IDs to each file, for example with sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 <user>, making sure it does not overlap other users' ranges. Then rerun the grep to confirm.