Docker 101: How to install Docker on Ubuntu Server 22.04
Docker 101: How to install Docker on Ubuntu Server 22.04
‘ZDNET Recommends’: What exactly does it mean?
ZDNET’s recommendations are based on many hours of testing, research, and comparison shopping. We gather data from the best available sources, including vendor and retailer listings as well as other relevant and independent reviews sites. And we pore over customer reviews to find out what matters to real people who already own and use the products and services we’re assessing.
When you click through from our site to a retailer and buy a product or service, we may earn affiliate commissions. This helps support our work, but does not affect what we cover or how, and it does not affect the price you pay. Neither ZDNET nor the author are compensated for these independent reviews. Indeed, we follow strict guidelines that ensure our editorial content is never influenced by advertisers.
ZDNET’s editorial team writes on behalf of you, our reader. Our goal is to deliver the most accurate information and the most knowledgeable advice possible in order to help you make smarter buying decisions on tech gear and a wide array of products and services. Our editors thoroughly review and fact-check every article to ensure that our content meets the highest standards. If we have made an error or published misleading information, we will correct or clarify the article. If you see inaccuracies in our content, please report the mistake via this form.
Docker 101: How to install Docker on Ubuntu Server 22.04
If you’ve ever wanted to up your tech game at home, you might consider adding containers into the mix. With containers, you can easily deploy your own services, such as the Nextcloud cloud server, WordPress, your own in-house, cloud-based office suite (such as OnlyOffice), and much more.
If you’ve never worked with this technology, you probably assume it’s too difficult to use. Fortunately, compared to some other container solutions, Docker is more user-friendly, offers plenty of GUI applications (so you don’t have to always work from the command line), and is supported by Linux, macOS, and Windows.
Also: Docker 101: Why you should be using containers
I’ve deployed hundreds of applications and services with this tool and found it to be an invaluable component of my everyday workflow. In many cases, deploying the containerized application via Docker is much faster and more reliable than deploying the same app/service manually.
How do you install Docker on Linux?
I’m going to show you how to do just that. I’ll demonstrate on Ubuntu Server 22.04, which means the process should work on any Ubuntu (or Debian) based distribution. As far as Red Hat Enterprise Linux-based distributions (such as Rocky Linux, AlmaLinux, CentOS Stream, and Fedora Linux), those platforms have migrated to Podman as their default container runtime, and installing Docker is not only very challenging, it tends to break more things than it fixes.
So, if RHEL-based distributions are your jam, leave well enough alone and stick with Podman. However, if Ubuntu-based distributions are the way you lean, Docker is not only available, it’s really easy to install. To that end, I’ll be demonstrating on Ubuntu Server 22.04.
What you’ll need: To install Docker on Ubuntu, you’ll need an Ubuntu-based distribution and a user with sudo privileges. Ready? Let’s get to the installation.
How to install Docker on Ubuntu
1. Add the necessary repository
The first thing to do is log in to your Ubuntu instance and add the necessary repository (as the version of Docker found in the standard repository isn’t the latest community edition we want). Once you’ve logged in, add the official Docker GPG key with the command:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Next, add the official Docker repository:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
2. Install the necessary dependencies
We’ll next install the required dependencies with the command:
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y
3. Install Docker
Finally, update apt and install Docker with the following commands:
sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io -y
4. Add your user to the docker group
In order to be able to use Docker without having to invoke it with sudo (which can lead to security issues), you must add your user to the docker group with:
sudo usermod -aG docker $USER
Log out and log back in for the changes to take effect.
Docker is now ready to use on your Ubuntu machine.
Testing the installation
Once Docker is installed, you can verify the installation by issuing the command:
docker version
In the output, you should see something like this:
Server: Docker Engine - Community Engine: Version: 20.10.14
Let’s make sure your user can run a Docker command by pulling down the hello-world image with:
docker pull hello-world
If the image successfully pulls, congratulations, Docker is installed and ready to go.
Add a Comment
You must be logged in to post a comment.