I’m running an Ubuntu 24.04 LTS (Noble) server on an AWS t3.large instance, and I need Docker to manage containers for my applications. In this guide, I’ll walk through the exact steps to install Docker and Docker Compose on Ubuntu 24.04, configure it to start on boot, and allow it to run without sudo.
Update System
Before installing, always update your package lists:
1 | sudo apt update |
Add Docker Repository and Prerequisites
Install required packages:
1
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common gnupg lsb-release
Add Docker’s official GPG key:
1
2curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgAdd the Docker repository:
1
2
3echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullUpdate apt index again:
1
sudo apt update
Install Docker
Install Latest Docker CE
1 | sudo apt install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin |
✅ These packages include:
- docker-ce → The Docker engine (daemon).
- docker-ce-cli → The Docker CLI tool (
docker
). - containerd.io → Container runtime used by Docker.
- docker-compose-plugin → Adds
docker compose
(modern Compose).
(Optional) Install a Specific Version
List available versions:
1 | apt-cache madison docker-ce |
Install a specific version (replace version strings as needed):
1 | sudo apt install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io |
Enable & Start Docker
Check Docker status:
1 | systemctl status docker |
If not running, enable and start:
1 | sudo systemctl enable docker |
Run Docker Without sudo
To avoid typing sudo
with every Docker command, add your user to the docker
group:
1 | sudo usermod -aG docker $USER |
⚠️ Log out and back in (or reboot) for the group change to take effect.
Test:
1 | docker ps -a |
Example:
1 | Docker version 28.4.0, build d8eb465 |
Install Standalone Docker Compose (Optional)
If you want the standalone docker-compose
binary in addition to docker compose
:
1 | sudo curl -L "https://github.com/docker/compose/releases/download/v2.28.1/docker-compose-$(uname -s)-$(uname -m)" \ |
Check version:
1 | docker-compose --version |