How to Install Docker on Ubuntu 22.04

Docker is an open software platform that allows you to build, test, and run applications in containers. Docker has an official repository for Ubuntu, so you can easily install it using apt package manager. Here are the steps to install Docker on Ubuntu 22.04.

 

1. Update the Package List:

Open a terminal window on your Ubuntu 22.04 server and update the local package database to ensure you have the latest information about available packages:

   ```bash

   sudo apt update

   ```

2. Install Required Dependencies:

Before installing Docker, you’ll need to make sure that some required packages are installed. You can do this with the following command:

   ```bash

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

   ```

3.Add Docker Repository:

Docker provides an official repository that contains the Docker package for Ubuntu. You can add this repository to your system:

   ```bash

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

   ```

Next, add the Docker repository to your sources list:

   ```bash

   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

   ```

4. Install Docker:

Update the package list again to include the Docker repository, and then install Docker:

   ```bash

   sudo apt update

   sudo apt install -y docker-ce docker-ce-cli containerd.io

   ```

 

5. Start and Enable Docker:

Docker should start automatically after installation, but you can ensure it’s enabled to start on boot with:

   ```bash

   sudo systemctl enable docker

   ```

6. Check Docker Version:

To verify that Docker has been installed successfully, you can check the version:

   ```bash

   docker --version

   ```

This should display the installed Docker version.
 

7. Test Docker Installation:

You can also run a simple test to verify that Docker is working correctly. Try running the following command, which should pull a small test image and run it in a container:

   ```bash

   sudo docker run hello-world

   ```

If everything is set up correctly, you’ll see a message confirming that your installation appears to be working correctly.

That’s it! Docker is now installed on your Ubuntu 22.04 system. You can start using Docker to manage and run containers.

Have additional questions? Search below: