
How to install the Docker engine on Ubuntu 22.04.4 LTS
Here is a quick overview with the basic steps how to install the Docker engine on a Ubuntu server. Before you start make sure you have access to a device running Ubuntu server and a server account with sufficient privileges.
Check out these sources for more information:
Source: https://www.docker.com/
Documentation: https://docs.docker.com/engine/install/ubuntu/
Start with an updated OS
Our target is virtual machine with Ubuntu Server version 22.04.4 LTS installed.
It is always a good idea to start with an up to date operating system so the first step will be updating/upgrading this machine with the latest patches.
sudo apt-get update
sudo apt-get upgradeUninstall old versions of Docker packages
Before you can install Docker Engine, you need to uninstall any potential conflicting packages.
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; doneInstall Docker using the apt repository
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
# 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 updateYou can now install the latest version by running these commands.
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginVerify that the Docker Engine installation is successful by running the hello-world image.
sudo docker run hello-world👇 Example output 👇
techfossa@techfossa-demo-01:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Already exists
Digest: sha256:53641cd209a4fecfc68e21a99871ce8c6920b2e7502df0a20671c6fccc73a7c6
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
techfossa@techfossa-demo-01:~$Time left? Check out the "Hello, World!" program page on Wikipedia:
https://en.wikipedia.org/wiki/%22Hello,_World!%22_program
Another way to check if the Docker engine is running is find out what version of the engine is installed.
docker --version👇 Example output 👇
techfossa@techfossa-demo-01:~$ docker --version
Docker version 26.0.0, build 2ae903e
techfossa@techfossa-demo-01:~$You are now ready to deploy more Docker containers on this host. 💯
Visit de Docker Hub to browse through the available images at https://hub.docker.com/Â
Have fun exploring the world of Docker containers for your projects!
Make sure to visit other sources to learn more about Docker containers. 🤓
