How To Install Docker On Ubuntu

Docker is an essential tool for modern development, and installing it on Ubuntu is quick and straightforward. In this guide, you’ll learn how to install Docker on Ubuntu step-by-step and run your first container in minutes.

Steps To Install Docker On Ubuntu

Step 1: Update Your Package Index

Before installing any new packages, it’s always good practice to update your local index:

sudo apt update
sudo apt upgrade -y

Step 2: Install Required Dependencies

Docker needs a few packages before it can be installed:

sudo apt install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release -y

Step 3: Add Docker’s Official GPG Key

This key ensures that you’re downloading authentic Docker packages:

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Step 4: Set Up the Docker Repository

Add the Docker repository to your APT sources:

echo \
  "deb [arch=$(dpkg --print-architecture) \
  signed-by=/etc/apt/keyrings/docker.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

Update your index again and install Docker:

sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y

Step 6: Verify Docker Installation

Check that Docker is installed and running:

sudo docker --version
sudo docker run hello-world

The hello-world image is a small container that prints a success message — a perfect way to confirm everything works.

Step 7: (Optional) Run Docker Without sudo

To avoid typing sudo every time:

sudo usermod -aG docker $USER
newgrp docker

Then test again:

docker run hello-world

You’ve successfully installed Docker on Ubuntu and run your first container. From here, you can start pulling images, creating containers, and even building your own Dockerfiles.

You can read more useful articles like Getting Started with Docker: A Beginner-Friendly Guide.

Follow us for the more helpful posts!

We hope this is a useful post for you.

Thank you for reading!

5 1 vote
Article Rating

Aaron LX

Aaron is a passionate writer, crazy about shopping, eCommerce and trends. Besides his outstanding research skills and a positive mind, Aaron eagerly shares his experience with the readers.

Leave a Reply or put your Question here

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x