14.6 C
Senior Writer and partner

How to install Docker on Ubuntu 18.04?

It is very likely that you know or have heard about Docker. This wonder that it is a great solution to software deployment problems. However, it is easy to install. This article will show you how to install Docker on Ubuntu 18.04.

Docker is an open source project designed to automate the large-scale deployment of applications within containers. The idea of doing this is to provide layers of abstraction that allow a program to run regardless of the operating system it runs. So, this is very useful for the sysadmin who manage many different computers.

Combining Docker with ubuntu 18.04 is practically a safe bet for the efficiency and ease of handling of containers.

0. Prerequisites

As you’ll see later, installing Docker on Ubuntu 18.04 is really simple. However, it requires that you have some knowledge about the use of the terminal.

- Advertisement -

In addition, your user should be able to run commands as root, because it requires installing additional packages and adding repositories.

Finally, it is recommended that you access the server using ssh with strong passwords.

1. Upgrade the system

The first step to install Docker in Ubuntu 18.04, is to update the system. I always recommend doing so because it is necessary to have a robust and secure system and this is obtained by installing the latest security patches issued by the Linux distribution you use, in this case, Ubuntu. So, run this command:

:~$ sudo apt update && sudo apt upgrade

1.- Upgrading the system
1.- Upgrading the system

In the end, you will have a more secure system and ready to continue the installation.

2. Add the Docker repository

Docker does not come by default in Ubuntu repositories, therefore, you have to add the particular Docker repository to install it via APT in an easy and secure way. However, first, you need to install some necessary packages.

:~$ sudo apt-get install apt-transport-https ca-certificates curl gnupg software-properties-common

2.- Install some required packages
2.- Install some required packages

Now add the GPG key from the Docker repository. This is to add even more security to the packages that will be downloaded.

:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

3.- Adding the GPG key for Docker repository
3.- Adding the GPG key for Docker repository

Then add the repository in question.

:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

4.- Adding the Docker repository
4.- Adding the Docker repository

Now you can proceed with the installation.

3. Install Docker on Ubuntu 18.04

It’s time to install Docker. Run the following command.

:~$ sudo apt install docker-ce

5.- Install Docker
5.- Install Docker

At the end of the installation. Have the service run at system startup.

:~$ sudo systemctl enable docker
:~$ sudo systemctl start docker

6.- Enabling and starting the Docker service
6.- Enabling and starting the Docker service

To ensure that Docker is fully functional, it is a good idea to check the status of the service.

:~$ sudo systemctl status docker

7.- Docker service status
7.- Docker service status

Finally, look at the Docker Version.

:~$ docker -v

8.-Docker Version
8.-Docker Version

Now that Docker is installed correctly, let’s do the first tests.

4. First steps

Docker has a lot of images for almost everything. It is necessary to look for the one we want, download it and use it. For example, I will look for an image that contains a LAMP server.

:~$ sudo docker search

9.- Search for Docker images
9.- Search for Docker images

As you can see in the image, there are several options. Choose the one you want and then download it.

:~$ sudo docker pull nickistre/ubuntu-lamp-wordpress


10.- Downloading a Docker image
10.- Downloading a Docker image

Now you can use it. If you want to list all the images you have installed. You can do it with this command.


:~$ sudo docker images

11.- Listing all Docker images downloaded
11.- Listing all Docker images downloaded

5. Run Docker without root privileges

So far you have run Docker as a root user, but this is not advisable. To run Docker without user privileges, run.

:~$ sudo usermod -aG docker $(whoami)

Then restart the computer and it’s done.


Docker is a novel technology and comes in a frank ascent. Many sysadmins see it as an essential part of their work. As you may have noticed, installing Docker on Ubuntu 18.04 is not difficult.

Tell us, have you used Docker? Do you work with Docker?

You can also read “How to install Docker on CentOS 7?“.

Please spread this article through your social networks


- Advertisement -
Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
"The best Linux newsletter on the web"



Please enter your comment!
Please enter your name here

Latest article