Skip to main content

Command Palette

Search for a command to run...

How to Install Docker Rootless on Ubuntu (2026 Guide)

Updated
3 min read
![Docker Rootless Installation on Ubuntu](https://i.imgur.com/iZXnlOf.png)

> **Quick one-liner:** All the container power, none of the root-level risk.

---

## Why This Matters

When I first started with Docker, I ran everything as root. It was easy, it worked, and I didn't think twice about it. Then I learned that a container escape vulnerability could give an attacker full root access to my entire system. That's when I switched to rootless Docker — and you should too.

Rootless Docker runs the Docker daemon entirely under your regular user account. No `sudo` required. No root privileges for container operations. If a container gets compromised, the attacker is stuck with your user's permissions — not root.

> **You asked, I delivered:** This guide was the #1 request in my LinkedIn poll (Ubuntu/Linux Mint won with 57% of votes).

## Planning Disk Space

In rootless mode, Docker stores all images, containers, volumes, and build cache under your home directory at `~/.local/share/docker`. This means your home directory needs enough space to hold everything you work with.

For following along with this guide, plan for at least **20 GB** of free space in your home directory.

Check your available space:
```bash
df -h ~
```

## Prerequisites

- **Operating System:** Ubuntu 22.04 or higher (also works on Linux Mint, Pop!_OS)
- **Disk Space:** At least 20 GB free in your home directory
- **Time:** 15-20 minutes
- **Access:** Sudo privileges for initial installation only

## Step 1: Remove Old Docker Packages

```bash
sudo apt remove docker.io docker-compose docker-compose-v2 \
    docker-doc podman-docker containerd runc
```

## Step 2: Set Up Docker's APT Repository

```bash
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
    -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
```

Add the Docker repository:
```bash
sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: \((. /etc/os-release && echo "\){UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
```

## Step 3: Install Docker Packages

```bash
sudo apt install docker-ce docker-ce-cli containerd.io \
    docker-buildx-plugin docker-compose-plugin
```

## Step 4: Install Rootless Prerequisites

```bash
sudo apt install uidmap dbus-user-session
```

## Step 5: Set Up Rootless Docker

Disable the system-wide Docker daemon:
```bash
sudo systemctl disable --now docker.service docker.socket
```

Run the rootless setup script as your regular user:
```bash
dockerd-rootless-setuptool.sh install
```

Enable your user's Docker service:
```bash
systemctl --user enable --now docker
sudo loginctl enable-linger [username]
```

Replace `[username]` with your actual username.

## Verification

**1. Test with hello-world:**
```bash
docker run hello-world
```

**2. Confirm rootless mode:**
```bash
docker info | grep -i context
```

You should see: `Context: rootless`

**3. Test with a real container (jq demo):**
```bash
echo '{"name":"David","company":"Transcend Solutions"}' > sample.json
cat sample.json | docker run --rm -i ghcr.io/jqlang/jq '.'
```

## Rootless Limitations

- **No ports below 1024** — rootless containers cannot bind to privileged ports
- **Storage in home directory** — all images live under `~/.local/share/docker`
- **No `ping` from containers** — ICMP requires root privileges

## What's Next

Now that you have a secure rootless Docker environment:
- Pull and run your first containers
- Learn about Docker volumes for persistent data
- Set up multi-container applications with Docker Compose

---

**Want more?** This guide is adapted from **Chapter 1: Preparing Docker Host** in my book **"Levelling Up with Docker"** — 14 chapters covering volumes, networking, Compose, production deployments, and more.

**Get it on Amazon:** https://www.amazon.com/dp/B0GGZ76PHW

---

**Published:** 4 March 2026  
**Author:** David Tio  
**Source:** Chapter 1: Preparing Docker Host  
**Tags:** Docker, Ubuntu, Linux, Rootless, DevOps, Tutorial

More from this blog

fosstechnotes

23 posts