Table of Contents

Choose a different version or distribution


Before we begin talking about how to install Docker on Ubuntu 18.04 OS, let’s briefly understand – What is Docker?

Docker is a platform that uses OS-level virtualization to deliver software in packages called containers. More than that, it is a popular tool to make build and deployments easier.

You’ll install Docker Community Edition (CE) on Ubuntu 18.04 in this tutorial. Also, we will answer some FAQs regarding Docker installation.


  • Ubuntu 18.04 64-bit operating system
  • A user account with sudo privileges
  • Command-line/terminal

Make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Step 1 – Uninstall Old Version of Docker

It is very important to remove any default Docker packages from the system before starting the installation process. Execute the below commands to remove unnecessary Docker versions.

sudo apt purge docker-ce 
sudo apt autoremove

Step 2 – Install Docker on Ubuntu 18.04

1) At first, update the package list and install the necessary dependencies.

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

2) Now, add the GPG key for the official Docker repository to your system.

curl -fsSL | sudo apt-key add -

3) After that, add the Docker repository to APT sources.

$ sudo add-apt-repository "deb [arch=amd64] bionic stable"

4) Now, update the package database with the Docker packages from the newly added repo.

sudo apt update

5) To make sure you are installing from the official Docker repo instead of the default Ubuntu repo run the following command.

apt-cache policy docker-ce

6) To install the latest version of Docker use the command below. If you want a specific Docker version, skip this step and jump to the 7th Step.

sudo apt install docker-ce

7) First list the available versions in the Docker repository to install a specific version.

apt list -a docker-ce

8) After that, run the following command to print the available Docker versions in the second column.

docker-ce/bionic 5:18.09.7~3-0~ubuntu-bionic amd64
docker-ce/bionic 5:18.09.6~3-0~ubuntu-bionic amd64
docker-ce/bionic 5:18.09.5~3-0~ubuntu-bionic amd64

9) For example, to install version 18.09.7 you can type the following.

sudo apt install docker-ce=5:18.09.7~3-0~ubuntu-bionic

10) Docker installation is done now. Check if it is running.

sudo systemctl status docker

11) The output will look something like this:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2020-01-13 19:15:29 UTC; 8min ago
 Main PID: 15160 (dockerd)
    Tasks: 10
   CGroup: /system.slice/docker.service
           └─15160 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.toml

Installing Docker gives not just the Docker service (daemon) but also the docker command-line utility, or the Docker client.

FAQs to Install Docker on Ubuntu

1) How to check if Docker is installed on the machine?

Run this command to check if Docker is available on your Ubuntu machine. If installed, you’ll see a similar output.

docker -v
Docker version 1.7.0, build 0baf609

If not installed, you’ll see a similar output.

docker -v
The program 'docker' is currently not installed. You can install it by typing:
apt-get install docker

2) Why do we require a GPG key downloading Docker packages?

This is not Docker-specific. Most Linux package managers have the ability to validate the integrity of a software package before installation by verifying it’s PGP (GPG) key.

When you’re configuring your system to install packages from one of those repositories, you have to add the public key so you can validate the image.

3) Docker-CE or package?

You can simply install Docker with the following single command.

sudo apt install

This is versioned and updated by Canonical/Ubuntu community members quite regularly but does tend to lag upstream a bit. For this reason, it is not much recommended.

4) Why should we run Docker as a non-root user?

Using the root user will enable the hackers to gain root access to the Docker host by hacking the application running inside the container. This is the major concern from a security perspective.


We hope this simple guide helped you understand how to install Docker on your Ubuntu 18.04 machine. To learn more about Docker installation for Ubuntu, check out the official Docker install documentation.

If you have any queries, please leave a comment below and we’ll be happy to respond to them for sure.

Docker - DevOps Tutorials - VegaStack
VegaStack publishes DevOps Tutorials about Git, CI/CD, DevSecOps, Cloud, Developer Hacks, Docker, Kubernetes, Serverless and more.
Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.