Installing Docker (compose) on Ubuntu
Abstract
Docker en Docker Compose are very usefull tools to quickly deploy containerized applications. Here's a step-by-step guide to installing Docker on Ubuntu.
Uninstall old versions
Before proceeding, especially if your Ubuntu OS is not a fresh install or Docker has been installed previously, it's recommended to remove any conflicting packages. Execute the command below to ensure a clean installation:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
Tip
You can follow the official Docker documentation for Ubuntu to ensure you have the most up-to-date instructions. Click here for the installation guide.
Setting up Docker's apt repository
We will need to add to official Docker APT
repository to your system.
This way, when you update your system in the future, it will automatically update to the lastest version of Docker.
Copy the command completely below and run it:
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get 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 repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Installing the latest version
Now that the repository has been added we can use a simple apt-get install
command to install the latest version of Docker and Docker Compose:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Testing the installation
You can verify that Docker is installed correctly by running:
And to check the status of Docker service:
That's it! Docker should now be successfully installed on your Ubuntu system. Happy containerizing!