How to Install Docker on Ubuntu

Linux

Introduction

Docker has become a fundamental tool in modern software development, enabling developers to package, distribute, and run applications in isolated containers. This article will guide you through the process of installing Docker on Ubuntu 20.04, one of the most popular Linux distributions.

Step 1: Update and Upgrade

Before installing Docker, it’s crucial to ensure that your system is up-to-date. Open a terminal and run the following commands:

Bash
sudo apt update
sudo apt upgrade

These commands will update the package lists and upgrade the existing packages to the latest versions.

Step 2: Install Docker Dependencies

Docker requires a few dependencies to be installed on the system. Run the following command to install them:

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

These packages are necessary for Docker to securely communicate with its repositories over HTTPS.

Step 3: Add Docker GPG Key

To verify the integrity of Docker packages, you need to add the Docker GPG key. Run the following command:

Bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Step 4: Set up Docker Repository

Add the Docker repository to the system’s APT sources:

Bash
echo "deb [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 5: Install Docker Engine

Now, update the package list again and install the Docker engine:

Bash
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
Step 6: Start and Enable Docker

Once the installation is complete, start the Docker service and enable it to start on boot:

Bash
sudo systemctl start docker
sudo systemctl enable docker
Step 7: Verify Docker Installation

To ensure that Docker is installed correctly, run the following command to check the Docker version:

Bash
docker --version

You should see information about the installed Docker version.

See also  How to Install Git on Ubuntu
Step 8: Test Docker with a Hello World Container

Run a simple Docker container to verify that everything is working as expected:

Bash
docker run hello-world

If everything is set up correctly, you’ll see a message indicating that your Docker installation is working.

Conclusion:

Congratulations! You’ve successfully installed Docker on your Ubuntu 20.04 system. Docker provides a powerful and flexible platform for developing, shipping, and running applications in containers. As you continue your journey with Docker, explore its vast ecosystem and discover how it can streamline your development and deployment processes.

See more:

Leave a Reply

Your email address will not be published. Required fields are marked *