04 March 2026

docker ubuntu linux devops

How to Install Docker Rootless on Ubuntu (2026 Guide)

Quick one-liner: Run Docker without sudo — safer, simpler, and no system-wide changes.


🤔 Why This Matters

I still remember the first time I saw a developer accidentally break a production server. They ran docker rm -f with a wildcard, and because Docker was running as root, it deleted system containers too. The entire server went down.

That's why I now install Docker in rootless mode by default.

Think of it like a seatbelt — you don't need it until you do. Rootless Docker means: - Your containers can't touch system files - No sudo required for daily operations - Damage is contained if something goes wrong

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


✅ Prerequisites


🔧 Step 1: Remove Conflicting Packages

Before installing Docker from the official repository, remove any conflicting packages from your distribution's defaults:

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

This ensures a clean starting point and prevents package conflicts.


🔧 Step 2: Configure Docker Repository

Install the required tools and add Docker's official GPG key:

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 apt repository:

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

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

What we're installing: - docker-ce — The Docker daemon - docker-ce-cli — The Docker CLI - containerd.io — Container runtime - docker-buildx-plugin — Extended build capabilities - docker-compose-plugin — Multi-container orchestration (docker compose)


🔧 Step 4: Install Rootless Prerequisites

sudo apt install uidmap dbus-user-session

What these do: - uidmap — Enables user namespace mapping (security isolation) - dbus-user-session — Required for user-level systemd services


🔧 Step 5: Disable System Docker Daemon

We want Docker running under your user account, not system-wide:

sudo systemctl disable --now docker.service docker.socket

🔧 Step 6: Run the Rootless Setup

Now run the rootless setup tool as your regular user (no sudo):

dockerd-rootless-setuptool.sh install

You should see output ending with:

[INFO] Installed docker.service successfully.
[INFO] To control docker.service, run: `systemctl --user (start|stop|restart) docker.service`
[INFO] To run docker.service on system startup, run: `sudo loginctl enable-linger [username]`
[INFO] Creating CLI context "rootless"
Current context is now "rootless"

🔧 Step 7: Enable on Boot

Enable your user's Docker service to start automatically:

systemctl --user enable --now docker

Enable lingering so your user services start at boot even without a login session:

sudo loginctl enable-linger $USER

Add the required environment variables to your shell:

echo 'export PATH=/usr/bin:$PATH' >> ~/.bashrc
echo 'export DOCKER_HOST=unix:///run/user/1000/docker.sock' >> ~/.bashrc
source ~/.bashrc

✅ Verification

1. Check context is rootless:

docker context show

Expected output:

rootless

2. Confirm rootless mode:

docker info | grep -i rootless

Expected output:

rootless

3. Check data directory:

docker info | grep "Docker Root Dir"

Rootless Docker stores everything under your home directory:

Docker Root Dir: /home/youruser/.local/share/docker

(Instead of /var/lib/docker for system Docker)

4. Test with a container:

docker run hello-world

Expected output:

Hello from Docker!
This message shows that your installation appears to be working correctly.

🔧 Troubleshooting

Problem: "Cannot connect to the Docker daemon"

The Docker service isn't running. Start it:

systemctl --user start docker

If that fails, check the status:

systemctl --user status docker

Problem: dockerd-rootless-setuptool.sh not found

The tool ships with docker-ce-rootless-extras. Install it:

sudo apt install docker-ce-rootless-extras

Problem: Containers can't access the network

Rootless Docker uses user namespaces, which can conflict with some network configurations. Try:

sudo sysctl -w net.ipv4.ip_unprivileged_port_start=0

To make this permanent:

echo "net.ipv4.ip_unprivileged_port_start=0" | sudo tee -a /etc/sysctl.conf

⚠️ Rootless Limitations to Know

Limitation Impact Workaround
No ports below 1024 Can't bind to ports 80, 443 directly Use a rootful reverse proxy
Storage in home directory Images/volumes use ~/.local/share/docker Ensure adequate home directory space
No ping from containers ICMP requires root privileges Use curl or wget for connectivity tests

These are minor trade-offs for the significant security benefit of never running the Docker daemon as root.


What's Next

Now that you have rootless Docker set up, you can skip ahead to Ep 3: Run Your First Docker Container.

If you're on SLES 16, stick around for Ep 2 — it's a bit unique and trickier to set up, so I'm covering it separately. Docker CE doesn't publish official packages for SLES, and the repository setup is different from Ubuntu.

Want more? I've written a full book on Docker — "Levelling Up with Docker" — with 14 chapters covering volumes, networking, Compose, and production best practices. Grab it on Amazon.


📢 Share This Guide

Found this helpful? Share it with someone learning Docker:

Questions? Drop a comment below or reach out on LinkedIn.

How to Install Docker Rootless on SLES 16 (2026 Guide) →