Installation Steps
Run these commands in order. I've broken them down so you know exactly what's happening to your system.
1. Update and Prep
First, make sure your package list is fresh and install a few terminal "helpers" that allow Ubuntu to communicate with a repository over HTTPS.
Bash
sudo apt update
sudo apt install ca-certificates curl gnupg lsb-release
2. Add Docker’s Official GPG Key
This ensures the software you're downloading is authentic and hasn't been tampered with.
Bash
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
3. Set Up the Repository
This tells your system exactly where to look for Docker updates in the future.
Bash
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
4. Install the Docker Engine
Now that the system knows where to go, update the index again and pull the trigger on the install.
Bash
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Quick Verification
To make sure everything is humming along nicely, run the classic "Hello World" container:
Bash
sudo docker run hello-world