> For the complete documentation index, see [llms.txt](https://fademaze.gitbook.io/fademaze-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fademaze.gitbook.io/fademaze-docs/docker/rootless-mode.md). Agents can also search and read this documentation through its [MCP server](https://fademaze.gitbook.io/fademaze-docs/~gitbook/mcp).

# Rootless mode

This shows you how to enable rootless mode on daemon level for Docker. Thanks to Brage!

1. Install Docker with the following command:

   ```
   sudo apt install curl -y && sudo curl -fsSL https://get.docker.com/ | sh
   ```
2. Add a Docker rootless user.

Start by running `sudo adduser docker_rootless --disabled-password`, then `sudo usermod -s /usr/sbin/nologin docker_rootless` to disable shells for the user.

3. Enable lingering to Docker rootless. Run `sudo loginctl enable-linger docker_rootless` **as root** and test if docker\_rootless has lingering with `ls /var/lib/systemd/linger/`.
4. Run `systemctl start user@$(id -u docker_rootless).service` to start lingering.
5. Install the dependencies with `sudo apt install uidmap` for uidmaps.

Next, log in as the rootless user with `sudo -u docker_rootless bash` and run `grep ^$(whoami): /etc/subgid` and `grep ^$(whoami): /etc/subuid`. The user needs at least 65,536 subordinate UIDs/GIDs, see this by looking at the files above.

***

```
If the third field is 65,536 or higher, you are done — skip the rest of this step. The ranges are usually allocated by the distribution already, and Docker needs 65,536 to map a full UID range.

If the number is too low, you have to extend the range. The ranges must never overlap between other users, so how you do it depends on where the user is in the file:

    If docker_rootless is the last line in the file, nothing can collide behind it. Just make the third field larger, for example docker_rootless:165536:1000000.

    If docker_rootless is not the last line, make sure that no other users use the UID/GIDs. Move the whole range below the last user instead. 
    Take the last line in the file, add the second and third fields together (like 100000 and 65536), and use the result on the first number:

        last line:        someuser:165536:65536
        new start:        165536 + 65536 = 231072
        new line:         docker_rootless:231702 (what you want to update):100000

    The third field is a count, not an end number: 231072:100000 means the IDs 231072 to 331072 (231072 plus 100000).
    Make sure the count is large enough as well, otherwise nothing is gained.

Repeat the exact same numbers in both /etc/subuid and /etc/subgid. Docker uses both UIDs and GIDs.
```

***

Now, go back to root with `exit` and run `systemctl stop user@$(id -u docker_rootless).service` and `systemctl start user@$(id -u docker_rootless).service`. Alternatively, reboot your machine.

Run `dockerd-rootless-setuptool.sh install` as the rootless user to check to test if the requirements are met. If it doesn't exist, run `sudo apt-get install -y docker-ce-rootless-extras`.

6. Install Docker rootless as the **docker\_rootless user** by running `dockerd-rootless-setuptool.sh install`.

:warning: DO NOT CLEAR THE SCREEN YET! Look at the output and put the relevant lines into `.bashrc`.

Finally, load it to your shell session:

```
source ~/.bashrc
```

6\. Test that Docker works by running `docker run --rm hello-world`.

If it still does not work...

<figure><img src="https://1791837826-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FPw7O35gbXTsFCCJ5jjrs%2Fuploads%2Fgit-blob-d548d5a602c30d2b622ed28923dec347e43b3d5b%2Fimage%20(1).png?alt=media" alt="" width="375"><figcaption></figcaption></figure>
