If you’re venturing into the world of containerization and looking for an efficient way to deploy applications, Docker is the tool you need. But what’s better than harnessing the power of containerization on a distro that’s an absolute joy to use?
Now, whyย Pop!_OS? Developed by System76, it is a Linux distribution based onย Ubuntu, specifically designed to meet all desktop computing needs while providing a beautiful and efficient user interface.
It has quickly become renowned for its strong, user-friendly approach, rich software repositories, and robust performance, delivering a seamless experience that leverages the best of Linuxโs ecosystem.
Now, to the subject. Installing Docker on Pop!_OS 22.04 LTS is a straightforward process. This guide is tailored to help you achieve a smooth setup and kickstart your Docker journey on a platform that champions efficiency and ease of use. So, let’s dive in!
Installing Docker on Pop!_OS 22.04 LTS
You can install Docker on your Pop!_OS 22.04 system in several ways. For example, it is available in the official distro’s repositories, where it can be easily installed with a single APT command. However, one disadvantage to this approach is that the version available is not always the most recent.
For this reason, this guide will show you how to install Docker on Pop!_OS 22.04 from the official Docker repository, where you always get the latest up-to-date version and will automatically receive all future software updates as they become available.
Step 1: Uninstall (If Any) Conflicting Packages
You can bypass this step if you’re confident that Docker has never been installed on your Pop!_OS 22.04. However, if there’s any chance Docker might have been previously installed, it’s strongly advised to execute the following command.
This step ensures the removal of any existing “docker,” “containerd,” and “runc” packages from your system, preventing potential conflicts with the installation process outlined below.
So, open the Terminal app and run the following:
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
Code language: JavaScript (javascript)
Step 2: Install Prerequisites
In this step, we’re going to install several extra packages. While these are not part of Docker’s core functionality, they must be available on your Pop!_OS 22.04 system as they are needed to import the official Docker repository smoothly into your system (described in the following steps).
sudo apt install apt-transport-https ca-certificates curl
Step 3: Add Dockerโs GPG Repo Key
Next, we must import the Docker GPG repository key. This security feature ensures that the software youโre installing is authentic.
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
Code language: JavaScript (javascript)
Notice that the command produces no output.
Step 4: Add the Docker Repo to Pop!_OS 22.04
After importing the GPG keys, weโll add the official Docker repository to our Pop!_OS 22.04 system. This implies that the update package will be made available with the rest of your systemโs regular updates when a new version is released.
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Code language: PHP (php)
As with the previous command, its execution produces no output. Next, refresh the package list.
sudo apt update
As you can see, our newly added Docker repository is now available and ready to be used.
Step 5: Install Docker on Pop!_OS 22.04 LTS
To install the latest up-to-date Docker release on your Pop!_OS 22.04 system, run the below command.
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Code language: CSS (css)
This installs the following Docker components:
- docker-ce: The Docker engine itself.
- docker-ce-cli: A command line tool that lets you talk to the Docker daemon.
- containerd.io: A container runtime that manages the containerโs lifecycle.
- docker-buildx-plugin: A CLI plugin that extends the Docker build with many new features.
- docker-compose-plugin: A configuration management plugin to orchestrate creating and managing Docker containers through compose files.
That’s all! Docker should now be installed; the service should start in the background and be automatically enabled to run on boot. Let’s check its status.
sudo systemctl is-active docker
Step 6: Verify the Docker Installation
Now letโs check if everything with our new Docker installation works properly. For this purpose, we will run a simple application called โhello-world.โ
sudo docker run hello-world
Congratulations! As we can see, everything works as expected!
Enabling Non-root Users to Run Docker Commands
So far, we have successfully installed Docker on our Pop!_OS 22.04 system. However, only root and users with sudo privileges can execute Docker commands by default.
In other words, if you attempt to run the docker
command without prefixing it with sudo
, youโll get an error message like this:
But don’t panic! To run Docker commands as a non-root user, you must first add your user to the “docker” group. It is a simple task. To do that, type in the following:
sudo usermod -aG docker ${USER}
In the above command, “${USER}” is a system environment variable that contains your username. To apply for the new group membership, reboot your Pop!_OS system.
You can then execute docker
commands without prefixing them with sudo
.
Conclusion
Docker is a powerful tool that can significantly enhance your ability to manage and deploy applications in a lightweight and efficient manner. By following the steps outlined in this article, you should have a working Docker installation on your Pop!_OS 22.04 system.
So, what are you waiting for? Start experimenting with it and see how it can revolutionize how you build and deploy applications.
To learn more about Docker, check out the official Docker documentation. Additionally, we recommend our detailed guide to expanding your skills with Docker and learning how to run and manage multi-container applications using Docker Compose. Happy dockering!