Docker has revolutionized the way developers create, deploy, and manage applications by enabling lightweight containerization technology, which allows for easy management and isolation of applications and their dependencies. In this tutorial, we will guide you through the process of installing Docker on Ubuntu 22.04, the latest long-term support (LTS) release of this popular Linux distribution. We will begin by discussing the benefits of using Docker and why it is essential for modern development workflows. Next, we will cover the necessary system requirements and prerequisites for a successful installation.
Before we begin, ensure that you have:
- A system running Ubuntu 22.04.
- A user account with sudo privileges.
Step 1: Update your system
Before installing any new software, it’s always a good idea to update your system packages. Open the terminal and run the following commands:
sudo apt update
sudo apt upgrade
Step 2: Install required dependencies
To install Docker on Ubuntu, we need to install some necessary dependencies first. Run the following command to install them:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker repository
Next, we will add the official Docker repository to our system. First, add the GPG key for the Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Then, add the Docker repository to your system with the following command:
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
Step 4: Install Docker
Now that we have added the Docker repository, update your package index:
sudo apt update
Then, install Docker with the following command:
sudo apt install docker-ce docker-ce-cli containerd.io
Step 5: Verify Docker installation
To verify that Docker has been installed successfully, run the following command:
sudo docker --version
You should see output similar to this, indicating the installed Docker version:
Docker version 24.0.6, build ed223bc
Step 6: Manage Docker service
Docker should now be installed and running as a background service. To check the status of the Docker service, run:
sudo systemctl status docker
If the Docker service is not running, you can start it with:
sudo systemctl start docker
To enable the Docker service to start automatically at boot, run:
sudo systemctl enable docker
Step 7: Running Docker without sudo (optional)
By default, Docker requires sudo privileges to run. If you want to use Docker without typing ‘sudo’ every time, add your user to the ‘docker’ group with the following command:
sudo usermod -aG docker $USER
After running this command, log out and log back in for the changes to take effect.
Congratulations! You have successfully installed Docker on your Ubuntu 22.04 system. You can now start using Docker to create, deploy, and manage your containerized applications. For more information on using Docker and its features, visit the official Docker documentation: https://docs.docker.com/.