Step-by-Step Guide- How to Install Docker on Ubuntu 21.04 in 2023
How to Install Docker on Ubuntu 21.04
Docker is a powerful platform that allows you to develop, ship, and run applications on any platform. Whether you are a developer or a system administrator, Docker can greatly simplify your workflow. In this article, we will guide you through the process of installing Docker on Ubuntu 21.04. By following these steps, you will be able to run Docker containers and take advantage of its many benefits.
Step 1: Update Your System
Before installing Docker, it is essential to ensure that your Ubuntu system is up-to-date. This will help prevent any potential issues during the installation process. To update your system, open the terminal and run the following command:
“`bash
sudo apt update
sudo apt upgrade
“`
Step 2: Install Prerequisites
Docker requires certain packages to be installed on your system. These packages will be used to build the Docker engine. Run the following command to install the necessary prerequisites:
“`bash
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
“`
Step 3: Add Docker’s GPG Key
To verify the authenticity of Docker packages, you need to add Docker’s official GPG key to your system. Run the following command to add the key:
“`bash
curl -fsSL gpg | sudo apt-key add –
“`
Step 4: Set Up the Docker Repository
Now that you have added the GPG key, you need to set up the Docker repository on your system. This will allow you to install Docker packages using the apt package manager. Run the following command to set up the repository:
“`bash
sudo add-apt-repository “deb [arch=amd64] $(lsb_release -cs) stable”
“`
Step 5: Install Docker Engine
With the Docker repository set up, you can now install Docker Engine. Run the following command to install the latest version of Docker:
“`bash
sudo apt install -y docker-ce
“`
Step 6: Verify the Installation
To verify that Docker has been installed successfully, run the following command:
“`bash
sudo docker –version
“`
The output should display the version of Docker that you have installed.
Step 7: Add Your User to the Docker Group
To run Docker commands without using `sudo`, you need to add your user to the Docker group. Run the following command to add your user to the Docker group:
“`bash
sudo usermod -aG docker $USER
“`
Step 8: Log Out and Log In Again
After adding your user to the Docker group, log out of your session and log in again. This will ensure that your user has the necessary permissions to run Docker commands without using `sudo`.
Conclusion
Congratulations! You have successfully installed Docker on your Ubuntu 21.04 system. Now you can start using Docker to containerize your applications and take advantage of its many benefits. To get started, refer to the Docker documentation and explore the vast ecosystem of Docker containers and tools. Happy Dockerizing!