Installing Docker on Linux comes down to one decision: always use the official Docker repository, not the version your distribution ships with. The packages in Ubuntu’s and Debian’s default repos fall behind fast. The official repo gives you the current stable release, the correct CLI, and the Compose plugin, everything you need to run an AI homelab stack.
Here’s how to do it.
Clear Out Old Versions
If you’ve tried Docker before, or your distribution installed a copy automatically, remove it first:
sudo apt remove docker.io docker-doc docker-compose podman-docker containerd runc
If none of these are installed, the command skips them. Either way, you get a clean slate.
Add the Official Repository
First, update your package index and install the tools Docker needs to set up its repository:
sudo apt update
sudo apt install ca-certificates curl gnupg
Then add Docker’s GPG key. This is how your system verifies that the packages it downloads are genuinely from Docker.
Ubuntu:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Debian:
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Now register the repository.
Ubuntu:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Debian:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
The two variables do the work automatically $(dpkg --print-architecture) detects your architecture, and $(lsb_release -cs) inserts your distro codename so the right packages are fetched.
Install Docker
Update your package index to pull in the new repository, then install:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
That installs the Docker daemon, the CLI, the container runtime, and the Compose plugin. The Compose plugin is what lets you run docker compose up to launch a full AI stack from a single file.
Configure Your User
Out of the box, every Docker command requires sudo. Fix that by adding your user to the Docker group:
sudo usermod -aG docker $USER
Then log out and back in. After that, docker ps works without sudo.
One thing worth knowing: being in the Docker group is equivalent to having root access on that machine. The Docker daemon can mount host filesystems and bypass normal permission boundaries. For a personal homelab, that trade-off is fine. On a shared system, be deliberate about who gets added.
The Takeaway
Docker is installed from the official repository, and your user is configured to run it without sudo. The engine is ready. The next step is actually using it, pulling images, and running your first container.
