Infrastructure
Docker Installation
Pre-Requisites

Before you begin, ensure that your system meets the following requirements:

  • Operating System: You need a 64-bit version of Ubuntu LTS version 22.04 (Jammy Jellyfish)
  • User Privileges: You should have sudo privileges to perform installations and configurations.
1. Set Up Docker's apt Repository

Docker Engine is installed from Docker's official repository. The first step is to set up this repository.

Add Docker's Official GPG Key:

Open a terminal and run the following commands to add Docker's GPG key, which is necessary for verifying the integrity of the Docker packages:

sudo apt-get update
sudo apt-get install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Add the Docker Repository to Apt Sources:

Next, add Docker's repository to your system's apt sources list:

 echo 
 'deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc]  https://download.docker.com/linux/ubuntu 
 $(. /etc/os-release && echo '
 $VERSION_CODENAME') stable' | \
 sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

This command configures your package manager to download Docker packages from Docker's official repository.

  • Note: If you're using a derivative of Ubuntu (like Linux Mint), you may need to replace VERSION_CODENAME with UBUNTU_CODENAME in the command above.
Update the Package Index:

After adding the repository, update the package index to include Docker's packages:

 sudo apt-get update
2. Install Docker Engine

Now that the repository is set up, you can install Docker Engine and its associated components.

Install the Latest Version of Docker Engine:

Run the following command to install Docker Engine, Docker CLI, containerd, and the Docker Compose plugin:

 sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Verify Docker Installation:

To verify that Docker Engine has been installed correctly, run the following command:

 sudo docker run hello-world

This command downloads a test Docker image (hello-world) and runs it in a container. If Docker is installed correctly, you will see a message that displays 'Hello form Docker'.

3. Install Docker Desktop (Optional)

If you haven't already, set up Docker's apt repository by following the steps in Step 1 above.

Download the Latest Docker Desktop DEB Package:

Download the latest version of the Docker Desktop package from Docker's official website download here and use the following command :

 sudo apt-get update
 sudo apt-get install ./path/to/docker-desktop-.deb
  • Note: Replace ` with your system's architecture (e.g.,amd64`).
Install Docker Desktop:
 systemctl --user start docker-desktop

This command will install Docker Desktop, allowing you to manage Docker through a user-friendly graphical interface.

Have a doubt?
Post it here, our mentors will help you out.