How to install docker on Ubuntu 18.04
Quick install docker install guide

How to install docker and docker-compose on Ubuntu 18.04

Mayur Chavhan Docker

Table of Contents


Overview

Docker-Image
Docker Container Image

 

Docker is an application that makes it simple and easy to run application processes in a container, which are like virtual machines, but more small, more resource-friendly, and more dependent on the host OS Kernel.

Docker-Compose in other hand is more advanced but fairly makes easy if you want to add multiple docker containers and services working together as a one using a single file. YML / YAML is language is used to create docker-compose file.

You’ll learn how to install and use it on an existing installation of Ubuntu 18.04.

 Docker requires a 64-bit version of Ubuntu also a kernel version requires to greater than 3.10.X

Ubuntu 18.04 doesn't comes with Docker official repository so we are going to add it and install it. Let's start with process to install Docker and Docker-Compose.

 Update System

First and most important is to update the system to keep all packages up to date so we don't run with outdated dependencies.

Run the following commands:

sudo apt update -qq -y

Install Prerequisite Packages

Once we have updated the system, we need to install some necessary packages before we are ready to install Docker. You can do this with the help of a single command:

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

Add Docker Repositories

Following steps is to add Docker Key and Repository to officially supported method for the Docker installation.

Add the GPG key using following command in terminal:

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

Next, Add the repository:

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

Update the repository information:

sudo apt update -y

Install Docker on Ubuntu 18.04

We are almost close. Use apt command to install Docker:

sudo apt install docker-ce -y

Start Docker

Once the installation is complete, Start the docker to enable the service:

sudo systemctl start docker

Check the service using below command if docker service is active or not.

sudo systemctl status docker


If all goes well then pat yourself in the back. Docker is installed on your Ubuntu machine. Now, Lets install Docker-Compose which is very easy now since we have docker installed on the machine.

Check if you have curl installed in your machine.

If not then install curl using following command:

sudo apt install curl

Install Latest Docker Compose

 
  1. To download the latest version of Docker Compose, run below command:

sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

At the time this article was written, Docker Compose 1.25.5 is the latest version but if you want to change latest version go to this release page.

https://github.com/docker/compose/releases


2. Give executable permission to docker-compose at installed location:

sudo chmod +x /usr/local/bin/docker-compose

 That's it, Now you've successfully installed docker-compose on your Ubuntu 18.04, Easy isn't it?