In the previous blogs posts , We have learnt how we can Setup Redash dashboards with the help of docker and docker compose.

So Let us understand the basics of Docker and the installation procedure of Docker and Docker compose.

What is Docker?

Docker is an opensource platform for developing , Shipping and running applications.

We can significantly reduce the delay between writing the codes and running applications in Production environment.

Using docker , We can segregate the applications from the infrastructure , By doing so we can quickly deliver the applications.

What is Docker Compose?

Docker compose is a tool for defining and running multi-container docker applications.

We will use YAML file to confgiure definitions for the applications and services.Once the compose file is ready , We can easily deploy and manage docker applications using the single file.

Docker compose is basically a three step process:

  • Define the application’s environment in Dockerfile
  • Define the services that will create an application in docker-compose.yml file so that they can run together in an isolated environments.
  • Then Run docker-compose up to start and run the applicationsĀ 

Docker compose can perform the following actions:

  • Start , Stop and Rebuild the services
  • Check the status of the running applications
  • Stream log out of the running services
  • Running a one-off command on a service

Example of Docker compose file.

version: '3'
services:
web:
image: nginx
db:
image: mysql
ports:
- "3306:3306"
environment:
- MYSQL_ROOT_PASSWORD=password
- MYSQL_USER=user
- MYSQL_PASSWORD=password
- MYSQL_DATABASE=testdb

What is Docker Engine?

Docker Engine is an Client-server application which has 3 major components.

  • A docker daemon (the dockerd command) , which is a long running program , Also referred as a service
  • A REST API which specifies the interface that programs can use to communicate with daemons and run commands against it.
  • docker command , a command line tool , called as docker client.

docker

Installing Docker packages.

Lets us install the stable version of docker using the below commands.

Update the apt index.

Run the below command , to update the packages lists for upgrading the packages and also the new packages that was added to the respository.

And install the below packages on the system to allow apt to use repositories over HTTPS.

sudo apt-get -qqy update

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

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

Adding the stable version of docker respository.

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

Before installing the latest stable version of Docker on Ubuntu systems, First we need to remove older version of docker installed on the system, Using the below command.

sudo apt-get remove docker docker-engine docker.io containerd runc

It will delete the above listed packages and its dependencies.

Installing the docker engine from the added repo.
sudo apt-get update && sudo apt-get -y install docker-ce

Start the docker service and check the status of Docker engine.

sudo systemctl start docker

sudo systemctl status docker

docker

We can check the version of docker engine installed.

sudo docker --version

docker

If you wish to install the specific version of docker engine from the repository.First list the available versions in the repo and then run then we will install the specific version of docker.

sudo apt-cache madison docker-ce

You can find the lists of available versions of docker.

docker

To install the specific version , Use can select the version string from the second column.

For example : 5:19.03.3~3-0~ubuntu-bionic

Lets install the above mentioned version using the below command.

sudo apt-get install docker-ce=5:19.03.3~3-0~ubuntu-bionic docker-ce-cli=5:19.03.3~3-0~ubuntu-bionic containerd.io

If you are installing custom version of docker and If the docker is already present on the system , The above commands with either Upgrade or Downgrade the docker version depending on the currently installed version of Docker.

Once installation is completed, Check the docker service and enable it to run on system boot.

Installing Docker Compose

Docker compose relies on docker engine , So make sure docker engine is installed on the system , either on local or remote.

Lets install the docker compose on the Ubuntu server.

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

Making the docker-compose binary file executable.

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

docker

You can check the version of docker-compose using the below command.

sudo docker-compose --version
docker-compose version 1.22.0, build f46880fe

docker

Conclusion

We have understood the basics of docker and we have learnt how to install docker engine and docker compose on the Ubuntu operating systems.

Hope you find it helpful.Please do check out my other publications.