Purpose
The purpose of this post is to document the installation of the docker application on a Debian based Linux distribution.
Scope
The scope is limited to just the installation process of the Docker application. It includes the prerequisite configurations and packages. Adding Docker images is out of scope and will be documented in other posts.
Background
Docker is a platform that packages applications and their dependencies into lightweight, portable containers that run consistently across all different types of operating environments. This includes physical servers, virtual servers and cloud infrastructure.
Using Docker allows me to run each application in its own container, isolated from both the host and other applications. This eliminates dependency conflicts such as issues with libraries. Uninstalling is just as simple as removing the container with no leftover files.
- Docker home is here: https://www.docker.com/
- What is a container: https://www.docker.com/resources/what-container/
- Getting started: https://www.docker.com/get-started/
Installation process
1. Update and upgrade the system.
sudo apt update
sudo apt upgrade -yThe “update” command tells “apt” to fetch the latest list of available packaged from all configured repositories. This ensures we get the latest version of software when we install the software packages in the next step.
The “upgrade” command is used to install available upgrades of all packages currently installed on the system to the latest versions. The “-y” automatically answers “yes” to the confirmation prompts.
2. Install Docker package prerequisites
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg -y- apt-transport-https: allows apt to use HTTPS
- ca-certificates: verifies SSL certificates
- curl: fetches files from the web
- software-properties-common: adds new repositories
- gnupg: handles cryptographic keys
3. Add Docker GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgGPG is the GNU Privacy Guard. It is an open-source encryption tool used for securing data.
- Use “curl” to download Docker’s official GPG key and stores it securely.
- This key will be used to verify the authenticity of Docker packages during the install
4. Add Docker Repository
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/nullThis command adds Docker’s repository to your system so you can install Docker from their official source. Note that you will need to replace “focal” with your Ubuntu version.(e.g., “jammy” for 22.04 and “noble” for 24.04).
Check with: “lsb_release -a” from the command line. Look for the Codename output.
5. Install the Docker engine
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io -yRefresh the “apt” package again so it recognises the newly added Docker repository.
Install Docker and all its components.The packages are:
- docker-ce: Docker Community Edition (the engine itself)
- docker-ce-cli: Command-line interface for Docker
- containerd.io: Core container runtime used by Docker
6. Enable and Start Docker
sudo systemctl enable docker
sudo systemctl start dockerThe “enable” step ensures Docker starts automatically on boot and “start” initiates the process immediately.
7. Add User to the Docker group
sudo usermod -aG docker $USERThis step lets you run Docker commands without using “sudo“
The “usermod” command modifies the user account settings.
After this point, log out and log in again to re-read the environment. I just rebooted instead.
8. Test Docker
docker run hello-worldThis step:
- contacts the docker daemon called “
dockerd“ - pulls the “
hello-world” image from Docker Hub - creates and runs container
- streams output to the terminal. See example below
Example Output…
$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
17eec7bbc9d7: Pull complete
Digest: sha256:6dc565aa630927052111f823c303948cf83670a3903ffa3849f1488ab517f891
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/
$