How to install Docker on Elementary OS 6.1 or any other Ubuntu-based Linux distribution via the terminal emulator?

I'm a passionate software developer.
Search for a command to run...

I'm a passionate software developer.
Other articles can be found here: https://blog.alexandrecalaca.com/all-articles
Components Introduction In order to truly understand props in React, we first need to be clear on what components are. A component is a reusable piece of the user interface that encapsulates structure, styling, and behavior. Instead of repeating the ...

Introduction Context By default, Codespace is using the GITHUB_TOKEN env var (the “Codespaces token”), which can’t create repos. It’s necessary to authenticate gh with a token/account that has the right scopes, or create the repo on the web first. Ob...

Solution Here it is: git commit --allow-empty-message -m "" Explanation To create a Git commit without a message, or with an empty message, you can use the --allow-empty-message flag with the git commit command. git commit --allow-empty-message -m "...

Steps Cleanup phase This phase’s goal is to removes existing containers, volumes, networks and images Stop and remove volumes docker compose down --volumes --remove-orphans The previous command stops and removes containers, networks, and default volu...

Steps Stop the service It’s not mandatory, but before uninstalling, it's a good practice to stop any running Docker services. sudo systemctl stop docker Remove docker packages It’s used to completely and forcefully remove a list of specified packag...

lsb_release -a
Output
lsb_release -a
No LSB modules are available.
Distributor ID: Elementary
Description: elementary OS 6.1 Jólnir
Release: 6.1
Codename: jolnir
The lsb_release -a command is used to display detailed information about the Linux distribution on your system.
It stands for "Linux Standard Base release" and provides information such as the distribution's name, release number, codename, and more
cat /etc/os-release
Output
cat /etc/os-release
NAME="elementary OS"
VERSION="6.1 Jólnir"
ID=elementary
ID_LIKE=ubuntu
PRETTY_NAME="elementary OS 6.1 Jólnir"
LOGO=distributor-logo
VERSION_ID="6.1"
HOME_URL="https://elementary.io/"
DOCUMENTATION_URL="https://elementary.io/docs/learning-the-basics"
SUPPORT_URL="https://elementary.io/support"
BUG_REPORT_URL="https://github.com/elementary/triage/issues/new"
PRIVACY_POLICY_URL="https://elementary.io/privacy-policy"
VERSION_CODENAME=jolnir
UBUNTU_CODENAME=focal
The cat /etc/os-release command in the terminal will display the contents of the /etc/os-release file, which contains information about the Linux distribution installed on your system.
if it's Ubuntu-based, you might see something in ID_LIKE,UBUNTU_CODENAME or another attribute.
sudo apt-get update
Running sudo apt-get update is an important step before installing or upgrading packages on your system because it ensures that you have the most up-to-date information about available packages.
Without updating the package index, you might not see the latest versions of software or be able to install new packages that have been added to the repositories since the last update.
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
In summary, the provided command is used to install essential packages and utilities that are commonly required for adding external repositories, securely fetching packages over HTTPS, and managing software sources on an Ubuntu system. These packages are often necessary for setting up and maintaining software on your system.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Output

sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
The command constructs a repository source entry for Docker, based on your distribution's codename (obtained using lsb_release -cs), and then writes that entry to the /etc/apt/sources.list.d/docker.list file.
This is how you add a Docker repository source to your APT configuration on a Debian-based system, ensuring that APT can find and install Docker packages from the specified repository.
sudo apt-get update
sudo apt-get install docker-ce
then
sudo apt-get install docker-ce-cli containerd.io
Output
docker --version
Output

which docker
Output

sudo systemctl status docker
Output

sudo docker run hello-world
You've made it!

I hope this article has been helpful to you. Please feel free to reach out if you have any questions. Your thoughts, suggestions, and corrections are more than welcome.
By the way, don't hesitate to drop your suggestions for new blog articles.
I look forward to seeing you next time.