Skip to main content
πŸŽ“ Claude Code Masterclass Learn AI-assisted development on Udemy β€” plus the companion book on Leanpub & Amazon. Start Learning
How to Install Docker on Arch Linux
DevOps

How to Install Docker on Arch Linux

Complete guide to install Docker Engine on Arch Linux: pacman setup, systemd service, Docker Compose, BuildKit, rootless mode, and AUR alternatives.

LB
Luca Berton
Β· 1 min read

Arch Linux ships Docker in the official repositories β€” no third-party repos needed. Here is the complete installation guide with post-install hardening.

Install Docker

# Update system and install Docker
sudo pacman -Syu docker docker-compose docker-buildx

# Start and enable the Docker daemon
sudo systemctl start docker
sudo systemctl enable docker

# Add your user to the docker group
sudo usermod -aG docker $USER

Log out and back in for group membership to take effect, or use newgrp:

newgrp docker

Verify Installation

docker --version
docker run hello-world
docker compose version
docker buildx version

You should see the hello-world container output confirming Docker is working.

Docker Compose and BuildKit

Both are included in the docker-compose and docker-buildx packages:

# Docker Compose V2 (plugin)
docker compose up -d

# BuildKit for faster builds
DOCKER_BUILDKIT=1 docker build -t myapp .

# Or enable BuildKit globally
sudo mkdir -p /etc/docker
echo '{"features":{"buildkit":true}}' | sudo tee /etc/docker/daemon.json
sudo systemctl restart docker

Rootless Docker

For enhanced security, run Docker without root privileges:

# Install rootless dependencies
sudo pacman -S fuse-overlayfs slirp4netns

# Set up rootless Docker
dockerd-rootless-setuptool.sh install

# Add to your shell profile
echo 'export DOCKER_HOST=unix://$XDG_RUNTIME_DIR/docker.sock' >> ~/.bashrc
source ~/.bashrc

Rootless Docker runs the daemon under your user account. Containers cannot escalate to root on the host.

Storage Driver

Arch Linux defaults to overlay2, which works well on ext4 and xfs. Check your current driver:

docker info --format '{{.Driver}}'

For btrfs filesystems, switch the storage driver:

// /etc/docker/daemon.json
{
  "storage-driver": "btrfs"
}

NVIDIA GPU Support

If you have an NVIDIA GPU for AI/ML workloads:

# Install NVIDIA Container Toolkit from AUR
yay -S nvidia-container-toolkit

# Configure Docker to use NVIDIA runtime
sudo nvidia-ctk runtime configure --runtime=docker
sudo systemctl restart docker

# Test GPU access
docker run --rm --gpus all nvidia/cuda:12.6-base nvidia-smi

Log Management

Prevent Docker logs from filling your disk:

// /etc/docker/daemon.json
{
  "log-driver": "json-file",
  "log-opts": {
    "max-size": "10m",
    "max-file": "3"
  }
}

Apply changes:

sudo systemctl restart docker

Alternative: Podman (Daemonless)

If you prefer a daemonless, rootless container runtime:

sudo pacman -S podman podman-compose

# Podman is CLI-compatible with Docker
podman run hello-world
podman compose up -d

# Optional: alias for muscle memory
alias docker=podman

See Podman vs Docker for a detailed comparison.

Troubleshooting

”Cannot connect to the Docker daemon”

# Check if the daemon is running
sudo systemctl status docker

# Check if your user is in the docker group
groups | grep docker

# If not, re-add and re-login
sudo usermod -aG docker $USER
# Then log out and back in

DNS resolution issues in containers

Arch Linux may use systemd-resolved, which can cause DNS issues in containers:

// /etc/docker/daemon.json
{
  "dns": ["8.8.8.8", "1.1.1.1"]
}

iptables vs nftables

Arch Linux uses nftables by default. If Docker has networking issues:

# Check which backend is active
sudo iptables --version
# If it shows nf_tables, Docker should work with recent versions
# For older Docker versions, switch to iptables-legacy:
# sudo pacman -S iptables-nft

Cleaning up disk space

# See Docker disk usage
docker system df

# Remove stopped containers, unused networks, dangling images
docker system prune -f

# Remove everything including unused images
docker system prune -a --volumes -f

Free 30-min AI & Cloud consultation

Book Now