This guide will walk you through how to install Docker on the widely supported Ubuntu OS. This will spare you on potential issues during installation and time spent on troubleshooting dependency conflicts from other potentially unsupported systems.
With the following commands:
sudo apt update
sudo apt upgrade
This installation will also install some dependencies as one bundle: containerd.io.
Because of this, already having these dependencies installed will conflict with a fresh install.
Remove them with:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
Note: the output might report that 0 dependencies were removed, because you might not have them. But it's still good to run the command to be sure.
First, you'll need to set up Docker's repistory by copy/pasting the following block of commands:
# 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
These commands will:
-
update the local package list with information about new packages
-
install
curlas well as theca-certificatesbundle of trusted Certificate Authorities -
install create the directory
/etc/apt/keyringsif it doesn't exist, and set permissions -
use
curlto download the GPG key file fromhttps://download.docker.com/linux/ubuntuinto the file in/etc/apt/keyrings/docker.asc -
set the
/etc/apt/keyrings/docker.ascGPG key file permissions -
in short, this long command creates a file that tells
aptpackage manager where to find the latest Docker software for your specific version of Ubuntu, and use a special GPG key to verify that the downloaded Docker software is genuine and untampered.
Install with the following command:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Confirm the install at the following prompt with:
y
Start with the following command:
sudo systemctl start docker
Verify proper Docker installation by accessing an image on Docker Hub:
sudo docker run hello-world
This makes managing your applications that implement Docker a little easier. You can just create one generic YAML file that will grab the specific containers and services that you need, and spin them up correctly so that they can communicate with each other. You will be spinning up a few different containers, and those containers are taking advantage of services from other containers.
For example, the front-end and back-end will be taking advantage of an OpenSearch container that will be running the OpenSearch service within it. So it needs to be able to not only install OpenSearch and get that up and running, but it also needs to communicate with it.
The Docker repository has already been set up.
So update the package index, and install Docker Compose with:
sudo apt-get update
sudo apt-get install docker-compose-plugin
Verify installation with:
docker compose version



