How to Install Docker Engine on Ubuntu: A Step-by-Step Guide

How to Install Docker Engine on Ubuntu: A Step-by-Step Guide

Learn how to install Docker on Ubuntu in this easy-to-follow guide for beginners. Just follow the steps and start using Docker in a matter of minutes.

Docker is a software platform that packages the application and all its dependencies in the containers – small and lightweight execution environments that share the operating system’s kernel but otherwise operate in isolation from one another.

They are similar to virtual machines, but containers are more portable and resource-friendly.

This article will show you the easiest way to install Docker on Ubuntu and get it running.

For a detailed introduction to the different components of a Docker container, you can check out our guide: What is a Docker Container: An Introductory Guide for Beginners.

Installing Docker on Ubuntu

Docker is available for installation from the standard Ubuntu repos, but it may not always be the latest version. So to ensure we get the newest version, we’ll install Docker from the official Docker repository.

1. Update Packages

First, update the packages index and install the dependencies necessary to add a new HTTPS repository.

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

2. Add the Docker Repo

Next, import the GPG key for the official Docker repository to your system. This security feature ensures that the software you’re installing is authentic.

curl -fsSL | sudo apt-key add -
Importing the Docker GPG key on Ubuntu

To be able to install Docker on your Ubuntu system, you must first add the stable Docker APT repository to it:

sudo add-apt-repository "deb [arch=amd64] $(lsb_release -cs) stable"
Adding Docker repository in Ubuntu

Finally, update the package database with the Docker packages from the newly added repo:

sudo apt update

3. Install Docker

To install the latest version of Docker on Ubuntu, run the command below. 

sudo apt install docker-ce docker-ce-cli
Install Docker on Ubuntu

Congratulations! Docker should now be installed; the service started and enabled to start on boot.

In addition, you can check the Docker state using:

sudo systemctl is-active docker
Check the Docker state on Ubuntu

When a new version of Docker is released, you can update the packages using the standard apt update procedure.

Enabling Non-root Users to Run Docker Commands

So far, we have successfully installed a Docker on your Ubuntu system.

Only root and users with sudo privileges can execute Docker commands by default. If you attempt to run the docker command without prefixing it with sudo, you’ll get an output like this:

Docker permission denied message on Ubuntu

To run Docker commands as a non-root user, you must add your user to the docker group. To do that, type in:

sudo usermod -aG docker ${USER}

In the command shown above, ${USER} is an environment variable that holds your username. To apply for the new group membership, log out and back in.


We’ve shown you how to install Docker on Ubuntu in this tutorial. To learn more about Docker, check out the official Docker documentation.

Bobby Borisov
Bobby Borisov

Bobby is an Editor-in-Chief at Linuxiac. He is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, Bobby has worked as a Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Leave a Reply

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