How to Install Docker On Ubuntu 20.04 & 22.04

Docker installation in ubuntu

To install Docker on Ubuntu 20.04 and 22.04, you can follow these steps. Docker has been a widely used containerization platform. However, it’s important to note that there might be newer alternatives or changes in the installation process beyond my knowledge cutoff date in September 2021. Be sure to check for the latest instructions from the Docker website or the official Ubuntu documentation.

Here’s how to install Docker on Ubuntu 20.04 and 22.04:

1. Update Your System:
First, ensure that your system is up to date by running the following commands:

   sudo apt update
   sudo apt upgrade

2. Install Required Dependencies:
Docker requires some dependencies to be installed. Install them with the following command:

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

3. Add Docker Repository:
Docker provides official packages for Ubuntu. To add the Docker repository, you can use the following commands:

For Ubuntu 20.04:

   curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
   echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] focal stable" | sudo tee /etc/apt/sources.list.d/docker.list

For Ubuntu 22.04 (if available):

   curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
   echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] jammy stable" | sudo tee /etc/apt/sources.list.d/docker.list

Please note that the repository URL might change, so check the Docker website for the most up-to-date instructions.

4. Install Docker:
Update the package list again and install Docker:

   sudo apt update
   sudo apt install docker-ce

5. Start and Enable Docker:
Start the Docker service and enable it to start on boot:

   sudo systemctl start docker
   sudo systemctl enable docker

6. Verify Docker Installation:
You can check the Docker version to ensure that it was installed successfully:

   docker --version

7. (Optional) Allowing Docker Without Sudo:
By default, you need to use sudo it to run Docker commands. If you want to use Docker without sudo, you can add your user to the “docker” group:

   sudo usermod -aG docker $USER

Then, log out and log back in for the changes to take effect.

That’s it! Docker should now be installed and running on your Ubuntu 20.04 or 22.04 system. You can start creating and managing containers using Docker.

Tagged :