How to Install Docker on Ubuntu 22.04

Docker on Ubuntu is an open-source platform facilitating the development, deployment, and execution of applications in lightweight, portable containers. These containers include all essential components for an application to run, ensuring a consistent environment across different systems. This makes it easier to manage and scale applications seamlessly throughout the software development lifecycle. Interested? Let’s take a look at all of the steps you’ll need to perform to install Docker on Ubuntu 22.04.

If you want a more detailed intro to the world of docker, you can explore the official website. It contains comprehensive documentation to help everyone get started. This guide will help you install Docker yourself, so make sure that you have the prerequisites addressed. And if you require any assistance at any step, feel free to contact us to get assistance. Let’s get started, shall we?

Prerequisites

Before we get started with the installation, make sure that you have the following:

  • Ubuntu 22.04 server or desktop
  • Non-root sudo user
  • Optional: A docker hub account if you want to create your own images and push them to the hub.

Update your system

Before diving into Docker installation, it’s crucial to ensure your system is up-to-date. Execute the following command:

$sudo apt update && sudo apt upgrade -y
sudo apt update

It will help by refreshing the package list and then upgrades the installed packages. This preemptive update minimizes the risk of conflicts during Docker installation on Ubuntu, ensuring a smoother process and optimal compatibility with your system. Taking this step helps maintain a secure and stable environment, setting the stage for a trouble-free Docker installation experience.

After this process completes, you’ll need to install some packages.

Method 1: Installing Docker through the official repository

If you want more control over the installation process, you can install docker from the official docker repository.

Installing the Docker pre-requisite packages

We need to install some packages using apt over HTTPS. Run the following:

$sudo apt install apt-transport-https ca-certificates curl software-properties-common
sudo apt install

Now import the GPG key to ensure the authenticity of the package:

$curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
curl -fsSL

After this import the repository:

$echo "deb [arch=$(dpkg --print-architecture) 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
echo

After successfully importing the and the repository and the key, make sure to run the update in order to include it in your list.

$sudo apt update
sudo apt update

Once the repository is imported, make sure that you are proceeding with the installation from the official Docker repo rather than the default Ubuntu repo. Run this to confirm:

$apt-cache policy docker-ce
apt-cache

With the output, you will see that “docker-ce” is not installed. With all of these steps complete, you are now ready to start installing docker.

Install Docker in Ubuntu

If you haven’t seen an error up to this point, you can start docker installation on Ubuntu by running the following:

$sudo apt install docker-ce
sudo apt install docker

After the installation completes, you will have the daemon started and the process enabled to start on boot. You can run the following to make sure that it is running:

$sudo systemctl status docker
sudo systemctl status docker

You will see a similar output. It means that you have been successful in the whole process.

Method 2: Installing through the default repository

If you want a more streamlined process and don’t want the hassle of manually updating Docker every time, you can install it from the default repository. After the update process, just run the following:

$sudo apt install docker.io -y
sudo apt install docker.io

Upon completion of the process, you can confirm the successful installation of Docker by checking its version. In this instance, we’ve verified the installation of Docker version 24.0.5. It’s important to note that while this version may not be the latest, as of the time of writing this post, it remains the most recent version available in the Ubuntu repository.

Run the following to make sure that docker is active and running:

$sudo systemctl status docker
sudo systemctl status docker

You’ll see the active status in the output. Let’s run a simple “Hello World” to confirm that Docker is correctly installed and working.

$sudo docker run hello-world
sudo docker run hello-world

Conclusion

Installing Docker on Ubuntu 22.04 opens up a world of efficient and scalable application deployment. Through the two methods discussed—utilizing the Docker repository for the latest version or the default repository for a stable release—you now have the flexibility to choose the approach that best suits your needs.

Whether you opt for bleeding-edge features or prioritize stability, Docker empowers you to streamline your development process and enhance application management. By following the steps outlined in this guide, you’ve equipped yourself with the knowledge to harness the power of Docker and elevate your software development experience on Ultahost’s Linux VPS platform. Happy containerizing!

FAQ

What is Docker?
How can I install Docker on Ubuntu 22.04?
How can I verify that Docker is installed correctly?
How can I run Docker commands without using sudo?

Related Post

How to Restart Ubuntu From Terminal

Restarting Ubuntu after updates, troubleshooting, or ro...

How to Install and Configure NFS on Ubuntu

NFS, which stands for Network File System, is a tool th...

How to Install Go on Ubuntu 22.04

Go, also known as Golang, is a modern programming langu...

How to Change the Timezone in Ubuntu

Ubuntu a popular Linux distribution allows users to adj...

How to Install R Language on Ubuntu

R is a popular language for statistical analysis and da...

How to Install Composer on Ubuntu 22.04

Composer has become an essential tool in PHP developmen...

Leave a Comment