Cloud Service >> Knowledgebase >> How To >> How to Install Docker Ubuntu 20?
submit query

Cut Hosting Costs! Submit Query Today!

How to Install Docker Ubuntu 20?

Installing Docker on Ubuntu 20.04 is an uncomplicated process. It allows you to implement containerization technology for your applications. Docker enables applications to operate safely within a container containing required dependencies and libraries.

Prerequisites

Ensure your system meets these requirements

- Ubuntu 20.04 is set up and operating.

- A user account with sudo privileges.

- Access to the terminal or command line.

Step 1: Update Your System

Updating your system to the latest version of packages and repositories is beneficial. Start a command line interface and execute the provided commands:

 

sudo apt update

sudo apt upgrade

This guarantees that your system is current and prepared for Docker installation.

Step 2: Install Required Packages

Docker requires some prerequisite packages to be installed. These packages are necessary for adding a new repository over HTTPS:

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

Step 3: Add Docker’s Official GPG Key

Add its official GPG key to your system. It verifies the authenticity of Docker packages.

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

Step 4: Add Docker’s APT Repository

Afterward, include the Docker repository in your APT sources.

 

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu focal stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Step 5: Update Package Database

After adding the Docker repository, update your package database again to include the Docker packages from the new repository:

sudo apt update

Step 6: Install Docker

Now you can install Docker using the following command:

sudo apt install docker-ce

The docker-ce package includes Docker Engine, the Docker CLI, and containerd. Confirm the installation by checking the Docker version:

docker --version

 

You should see an output like Docker version 20.10.7, build f0df350.

Step 7: Manage Docker as a Non-Root User

By default, Docker requires root privileges.

For a non-root user to execute Docker commands, they should be added to the group:

sudo usermod -aG docker $USER

 

After executing this command, log off sign in to see if the changes take effect. Verify that your user can run Docker commands without sudo:

 

docker run hello-world

This instruction downloads a sample image and executes it within a container. If the installation is completed successfully, a message will appear to confirm that Docker is functioning properly.

Step 8: Enable Docker to Start on the Boot

To ensure that Docker starts automatically at boot time, enable the Docker service:

sudo systemctl enable docker

Step 9: Running Your First Docker Container

You can use Docker to run containers when it is installed and running. For example, to run an Ubuntu container, use the following command:

docker run -it ubuntu

 

This command pulls the latest Ubuntu image from Docker Hub and starts a container in interactive mode with a terminal session.

 

Step 10: Basic Docker Commands

Here are some fundamental Docker commands to assist you get started:

 

- List Docker images:

- List running containers:

docker ps

- Stop a running container:

docker stop

- Remove a container:

docker rm

- Remove an image:

docker rmi

To Sum it Up!

Setting up Docker on Ubuntu 20.04 requires updating the system, installing essential packages, adding Docker's GPG key and repository, and finally installing Docker. Using this step-by-step tutorial, you will have Docker installed and working on your Ubuntu machine, all set to handle containers for your apps.

 

Docker makes it easier to deploy applications by bundling them with their dependencies, guaranteeing consistent and reliable performance in various environments. With Docker installed, you can utilize its robust features and tools to improve your development and deployment processes.

Cut Hosting Costs! Submit Query Today!

Grow With Us

Let’s talk about the future, and make it happen!