Install Docker Engine on Ubuntu

Install Docker Engine on Ubuntu

June 2024

In this quick tutorial we will install Docker Engine on Ubuntu using the Docker apt repository. This tutorial is an abbreviated version of the docker docs found here:  https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository. 

Remove Conflicting Docker Versions

We will first remove / uninstall any conflicting docker versions: 

							
							
					for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done				
			

Add the Docker Apt Repository

We will now add the docker apt repository to our server / desktop

							
							
					# 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				
			

If you are running an Ubuntu derivative such as Linux Mint you may need to run the following instead:

							
							
					# 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 "$UBUNTU_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update				
			

Install the Docker Packages

Now we will install docker engine from the docker apt repository:

							
							
					sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin				
			

Check Installation

Next we can ensure docker successfully installed by running the docker hello world image

							
							
					sudo docker run hello-world				
			

That’s it, docker is successfully installed on your server / desktop, for an indepth guide and more info see the official docker docs at: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository.

Walter Miely is a tech entrepreneur and CEO of Phoenix Ignited Tech You can find him on Linkedin. This material is licensed under the CC BY 4.0 License LEGAL DISCLAIMER: The content provided here is provided AS IS, and part of, or the entirety of this content may be incorrect. Please read the entireLegal Disclaimer here.