Docker installation steps on Ubuntu

Updated on

Prerequisites

For non-Gnome Desktop environments, gnome-terminal must be installed:

sudo apt install gnome-terminal

Uninstall the tech preview or beta version of Docker Desktop for Linux. Run:

sudo apt remove docker-desktop

For a complete cleanup, remove configuration and data files at $HOME/.docker/desktop, the symlink at /usr/local/bin/com.docker.cli, and purge the remaining systemd service files.

rm -r $HOME/.docker/desktop
sudo rm /usr/local/bin/com.docker.cli
sudo apt purge docker-desktop

Install Docker Engine on Ubuntu

1. Uninstall old versions

sudo apt-get remove docker docker-engine docker.io containerd runc

2. Setup the repository

Update the apt package index and install packages to allow apt to use a repository over HTTPS:

sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

Add Docker’s official GPG key:

sudo mkdir -p /etc/apt/keyrings

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Use the following command to set up the repository:

echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Update the apt package index:

sudo apt-get update

Install Docker Engine, containerd, and Docker Compose

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

Verify that the Docker Engine installation is successful by running the hello-world image:

sudo docker run hello-world

This command downloads a test image and runs it in a container. When the container runs, it prints a confirmation message and exits.

3. Download latest DEB package from the link:

https://desktop.docker.com/linux/main/amd64/docker-desktop-4.16.2-amd64.deb?utm_source=docker&utm_medium=webreferral&utm_campaign=docs-driven-download-linux-amd64

4. Install the package with apt as follows:

Replace the the script after ./ with the name of the file you downloaded from the link above

sudo apt-get update
sudo apt-get install ./docker-desktop-<version>-<arch>.deb

5. Launch Docker Desktop

systemctl --user start docker-desktop

Hi I'm Sudheer. I'm a MSc Advanced Computer Science student at Swansea University in Wales, UK. I share my learning resources on this blog. These include notes I created on various topics, step by step guides on how to implement things and documentation of whatever projects I'm working on.

Leave a Comment