• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

TinyGrab

Your Trusted Source for Tech, Finance & Brand Advice

  • Personal Finance
  • Tech & Social
  • Brands
  • Terms of Use
  • Privacy Policy
  • Get In Touch
  • About Us
Home » How to install Docker on Ubuntu 21.04?

How to install Docker on Ubuntu 21.04?

May 31, 2025 by TinyGrab Team Leave a Comment

Table of Contents

Toggle
  • Installing Docker on Ubuntu 21.04: A Definitive Guide
    • Step-by-Step Docker Installation
    • Detailed Installation Instructions
      • Updating the Package Index
      • Installing Required Packages
      • Adding Docker’s GPG Key
      • Setting Up the Docker Repository
      • Updating the Package Index Again
      • Installing Docker Engine
      • Verifying the Installation
    • Troubleshooting Common Issues
    • Frequently Asked Questions (FAQs)
      • 1. What is Docker and why should I use it?
      • 2. Is Docker free to use?
      • 3. How can I check the Docker version?
      • 4. How do I start, stop, and restart the Docker service?
      • 5. How do I run Docker commands without sudo?
      • 6. How do I remove Docker from Ubuntu 21.04?
      • 7. What is a Docker image?
      • 8. What is a Docker container?
      • 9. How do I pull a Docker image from Docker Hub?
      • 10. How do I list all the Docker images on my system?
      • 11. How do I list all the running Docker containers?
      • 12. What is Docker Compose?

Installing Docker on Ubuntu 21.04: A Definitive Guide

Installing Docker on Ubuntu 21.04 (Hirsute Hippo) is a straightforward process, essential for anyone venturing into containerization. This guide provides a meticulous walkthrough, ensuring a smooth and successful Docker installation on your Ubuntu system.

Step-by-Step Docker Installation

Here’s the condensed recipe for getting Docker up and running on Ubuntu 21.04:

  1. Update Package Index: Kick things off with sudo apt update to ensure you have the latest package information.
  2. Install Required Packages: These dependencies are crucial. Install them using sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release.
  3. Add Docker’s GPG Key: Authenticate the Docker repository with curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg.
  4. Set Up the Docker Repository: Add the Docker repository to your system using echo "deb [arch=$(dpkg --print-architecture) 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.
  5. Update Package Index Again: Re-run sudo apt update to include the Docker repository.
  6. Install Docker Engine: Install the Docker Engine, containerd, and Docker Compose with sudo apt install docker-ce docker-ce-cli containerd.io.
  7. Verify the Installation: Finally, confirm Docker is running smoothly with sudo docker run hello-world.

Detailed Installation Instructions

Let’s dissect each step for a deeper understanding and foolproof execution.

Updating the Package Index

Before installing any new software, refreshing the local package index is paramount. This ensures you’re downloading the most recent versions of the required packages.

Execute the following command in your terminal:

sudo apt update 

Installing Required Packages

Docker relies on several helper packages for secure and reliable operation. These packages facilitate secure communication and repository management.

Install them using:

sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release 

Each package plays a vital role:

  • apt-transport-https: Allows APT to access repositories over HTTPS.
  • ca-certificates: Provides trusted CA certificates.
  • curl: A command-line tool for transferring data with URLs.
  • gnupg: GNU Privacy Guard for secure communication.
  • lsb-release: Provides information about the Linux distribution.

Adding Docker’s GPG Key

Authenticity is key! Docker signs its packages to prevent tampering. The GPG key allows your system to verify the integrity of the Docker packages.

Execute the following command:

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

This command downloads the GPG key from Docker’s official website and adds it to the trusted keyring.

Setting Up the Docker Repository

Now, you need to tell your system where to find the Docker packages. This involves adding the official Docker repository to your APT sources.

Run this command carefully:

echo "deb [arch=$(dpkg --print-architecture) 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 

This command adds a new entry to your system’s APT sources list, pointing to the Docker repository. It also specifies the architecture and ensures the repository is authenticated using the GPG key.

Updating the Package Index Again

With the new repository added, update the package index once more to include the available Docker packages.

sudo apt update 

Installing Docker Engine

Finally, the moment you’ve been waiting for: installing the Docker Engine! This includes the core Docker components: docker-ce, docker-ce-cli, and containerd.io.

Execute the following command:

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

This command downloads and installs the Docker Engine and its dependencies.

Verifying the Installation

Confirm that Docker is installed and running correctly by running the “hello-world” container.

sudo docker run hello-world 

If the installation was successful, you’ll see a message confirming that Docker is working correctly. This message indicates that Docker has successfully pulled the hello-world image from the Docker Hub, created a container from it, and executed it.

Troubleshooting Common Issues

If you encounter problems during installation, here are some common issues and their solutions:

  • Repository Not Found: Double-check that you’ve added the Docker repository correctly and that your Ubuntu version is supported.
  • GPG Key Error: Ensure the GPG key was added correctly and that your system’s date and time are accurate.
  • Package Conflicts: Resolve any package conflicts by removing conflicting packages or using the apt --fix-broken install command.
  • Docker Service Not Running: Start the Docker service manually using sudo systemctl start docker.

Frequently Asked Questions (FAQs)

Here are some frequently asked questions about installing and using Docker on Ubuntu 21.04.

1. What is Docker and why should I use it?

Docker is a containerization platform that allows you to package applications and their dependencies into standardized units called containers. This ensures that your applications run consistently across different environments, from development to production. Docker simplifies deployment, improves resource utilization, and enhances application portability.

2. Is Docker free to use?

The Docker Community Edition (Docker CE) is free and open-source. Docker also offers a paid version called Docker Enterprise Edition (Docker EE) with additional features and support. For most individual developers and small teams, Docker CE is sufficient.

3. How can I check the Docker version?

You can check the Docker version by running the following command:

docker --version 

This will display the Docker Engine version installed on your system.

4. How do I start, stop, and restart the Docker service?

You can manage the Docker service using the systemctl command:

  • Start: sudo systemctl start docker
  • Stop: sudo systemctl stop docker
  • Restart: sudo systemctl restart docker
  • Check status: sudo systemctl status docker

5. How do I run Docker commands without sudo?

To run Docker commands without sudo, you need to add your user to the docker group:

sudo usermod -aG docker $USER newgrp docker 

After running these commands, log out and log back in for the changes to take effect.

6. How do I remove Docker from Ubuntu 21.04?

To completely remove Docker, follow these steps:

  1. Stop the Docker service: sudo systemctl stop docker
  2. Remove the Docker packages: sudo apt purge docker-ce docker-ce-cli containerd.io
  3. Remove Docker images, containers, volumes, and networks: sudo rm -rf /var/lib/docker
  4. Remove Docker configuration files: sudo rm /etc/apt/sources.list.d/docker.list

7. What is a Docker image?

A Docker image is a read-only template that contains instructions for creating a Docker container. Images are built from a Dockerfile, which specifies the application, libraries, and dependencies needed to run the application. Think of it as a blueprint for creating a container.

8. What is a Docker container?

A Docker container is a runnable instance of a Docker image. It is a lightweight, standalone, and executable package of software that includes everything needed to run an application: code, runtime, system tools, system libraries, and settings. Containers isolate applications from each other and the underlying infrastructure.

9. How do I pull a Docker image from Docker Hub?

You can pull a Docker image from Docker Hub using the docker pull command:

docker pull <image_name>:<tag> 

For example, to pull the latest version of the Ubuntu image, you would run:

docker pull ubuntu:latest 

10. How do I list all the Docker images on my system?

You can list all the Docker images on your system using the docker images command:

docker images 

This will display a list of all available images, including their repository, tag, image ID, and size.

11. How do I list all the running Docker containers?

You can list all the running Docker containers using the docker ps command:

docker ps 

To list all containers (running and stopped), use the -a flag:

docker ps -a 

12. What is Docker Compose?

Docker Compose is a tool for defining and running multi-container Docker applications. It uses a YAML file to configure your application’s services and dependencies. Docker Compose simplifies the process of managing complex applications by allowing you to start, stop, and rebuild all the services with a single command. It often gets installed together with Docker, but you should double-check if it’s available on your system by running docker-compose --version. If not, you can install it using sudo apt install docker-compose.

Filed Under: Tech & Social

Previous Post: « Is a backpack considered a personal item on American Airlines?
Next Post: What happens to the federal estate tax exemption in 2026? »

Reader Interactions

Leave a Reply Cancel reply

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

Primary Sidebar

NICE TO MEET YOU!

Welcome to TinyGrab! We are your trusted source of information, providing frequently asked questions (FAQs), guides, and helpful tips about technology, finance, and popular US brands. Learn more.

Copyright © 2025 · Tiny Grab