Install Docker on Debian/RHEL Based Linux Distros
What is Docker?
Docker is a platform that automates the deployment, scaling, and management of applications using containerization. Containers are lightweight, executable software packages that include everything needed to run a piece of software, such as the code, runtime, system tools, libraries, and settings. Docker enables developers to package applications and their dependencies into containers, ensuring consistency across multiple development, testing, and production environments. This approach enhances efficiency, scalability, and portability, making it easier to develop, ship, and run applications anywhere.
Yes but what is it really??
Docker is a tool for deoplying containers.
Containers (roughly speaking) can be concidered to be light weight Virtual Machines.
Containers may include all necessary dependencies for an application, ensuring it runs consistently across different environments while isolating the app from the host system.
The main differences between them are that VMs run a full operating system along with virtualized hardware, making them heavier and slower to start. Containers, on the other hand, share the host OS kernel and isolate applications at the process level, making them much more lightweight, faster to start, and efficient in terms of resource usage. This allows for greater scalability and flexibility in deploying applications.
Installation (Debian/RHEL)
For Debian based (Ubuntu/Pop!_OS/Mint and more)
# 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
# Install The Latest Version
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
For Alma/REHL
# Make sure system is updated
sudo dnf --refresh update
sudo dnf upgrade
# Install yum-utils
sudo dnf install yum-utils -y
# Add the repository
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# Install the latest Version
sudo dnf install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Start and enable the service
sudo systemctl start docker
sudo systemctl enable docker
Lastly verify that the Docker Engine installation is successful by running the hello-world image. (A simple test image)
sudo docker run hello-world
If all went well you should see the following output:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:d1b0b5888fbb59111dbf2b3ed698489c41046cb9d6d61743e37ef8d9f3dda06f
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/
All Done!!
Congratulations!!
You now have Docker daemon installed and running.
Next, lets find out how we can unleash its power!!
Docker Journey
If you started your Docker Journey, your next step will be going over some Docker basic command in this Post