Databasetechnology

How to install Docker on Ubuntu 18.04

To learn how to install Docker on Ubuntu 18.04, you need to understand what the tool is.  Docker is a tool designed to simplify the process of managing applications by making it easier to create, deploy, and run these applications using containers. So, containers permit a developer to bundle up an application with all the parts it needs such as libraries and other dependencies and deploy it as a single package.

There are two versions of Docker;

  • Docker CE (Community Edition)
  • Docker EE (Enterprise Edition)

If you have a small-scale project, or you’re just learning, you will want to use Docker CE.

Conditions for installation of docker on Ubuntu 18.04

  • One Ubuntu 18.04 server set up by following the Ubuntu 18.04 initial server setup guide, including a sudo non-root user and a firewall.
  • An account on Docker Hub if you wish to create your own images and push them to Docker Hub.
  • Docker software repositories (optional).

Steps on the installation of Docker on Ubuntu 18.04

Docker can be installed in different ways:

Option 1: Install Docker on Ubuntu Using Default Repositories

Step 1: Update Software Repositories

It’s a good idea to update the local database of software to make sure you have access to the latest versions.

Open a terminal window and type: 

sudo apt-get update

Allow the operation to complete.

Step 2: Uninstall Old Versions of Docker

Next, it’s recommended to uninstall any old Docker software before proceeding.

Use the command:

sudo apt-get remove docker docker-engine docker.io
Step 3: Install Docker on Ubuntu 18.04

To install Docker on Ubuntu, in the terminal window enter the command:

sudo apt install docker.io
Step 4: Start and Automate

The Docker service needs to be set up to run at startup. To do so, type in each command followed by enter:

sudo systemctl start docker
sudo systemctl enable docker
Step 5 (Optional): Check Docker Version

To verify the installed Docker version number, enter:

docker --version

Option 2: Install Docker from Official Repository

Step 1: Update Local Database

Update the local database with the command:

sudo apt-get update
Step 2: Download Dependencies

You’ll need to run these commands to allow your operating system to access the Docker repositories over HTTPS.

In the terminal window, type:

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

To clarify, here’s a brief breakdown of each command:

  • apt-transport-HTTPS: Allows the package manager to transfer files and data over HTTPS
  • ca-certificates: Allows the system (and web browser) to check security certificates
  • curl: This is a tool for transferring data
  • software-properties-common: Adds scripts for managing software
Step 3: Add Docker’s GPG Key

The GPG key is a security feature.

To ensure that the software you’re installing is authentic, enter:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add
Step 4: Install The Docker Repository

To install the Docker repository, enter the command:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

The command below scans and returns the codename of your Ubuntu installation – in this case, Bionic.

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

https://download.docker.com/lin
ux/ubuntu $(lsb_release -cs)

stable"

Also, the final word of the command stable is the type of Docker release.

Step 5: Update Repositories

Update the repositories you just added:

sudo apt-get update
Step 6: Install the Latest Version of Docker

Now, to install the latest version of docker:

sudo apt-get update
Step 7(Optional): Install Specific Version of Docker

List the available versions of Docker by entering the following in a terminal window:

apt-cache madison docker-ce

The system should return a list of available versions as in the image above.

At this point, type the command:

sudo apt-get install docker-ce=[version]

However, substitute [version] for the version you want to install (pulled from the list you just generated).

For example:

What's your reaction?

Excited
0
Happy
0
In Love
0
Not Sure
0
Silly
0

Leave a reply

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

Next Article:

0 %