Docker can be installed on several types of environments. ranging from Linux, via Apple's OSX to Microsofts Azure and Windows 10. A ready environment can be obtained from Amazon AWS, Google Cloud Platform, Microsoft Azure, and a number of independent cloud providers like Digital Ocean and Rackspace. This tutorial will show how to install Docker and optionally Docker Compose on Debian and Redhat Enterprise based Linux Distributions.

Install Docker on various Linux Distributions

Docker is one of the easiest ways to build, ship and run your applications across various environments. Using container virtualization, it enables you to run applications in Amazon’s AWS, Google Cloud Platform, Azure, VMWare vCloud or whatever other cloud platform your company might use. As a developer, you can also run it on your standard Windows or Apple desktop/laptop. Perfect for DEVOPS, perfect for Hybrid and multi supplier cloud environments because Docker containers can be run as easily on any cloud platform you might use. This how-to will explain how a Docker environment in which you can create application environments, ship them to the Docker registry and/or Run them and includes the optional installation of Docker compose.

How Does Docker Work?

Before we start with the installation it’s good to know a little bit about how Docker works. Docker has a client-server architecture. Docker Daemon or server is responsible for all the actions that are related to containers. The daemon receives the commands from the Docker client though cli or REST API’s. Docker client can be on the same host as daemon or it can be present on any other host. Images are the basic building blocks of Docker. Containers are built from images. Images can be configured with applications and used as a template for creating containers. Images are organized in a layered manner. Every change in an image is added as layer on top of it.

Docker registry is a repository for Docker images. Using Docker registry, you can build and share images with your team. A registry can be public or private. Docker Inc provides a hosted registry service called Docker Hub. It allows you to upload and download images from a central location. If your repository is public, all your images can be accessed by other Docker hub users. You can also create a private registry in Docker Hub. Docker hub acts like git, where you can build your images locally in your laptop, commit it and then can be pushed to the Docker hub.

Docker containers are created from images. It is a writable layer of the image. You can package your applications in a container, commit it and make it a golden image to build more containers from it. Two or more containers can be linked together to form tiered application architecture. Containers can be started, stopped, committed and terminated.

The best feature of Docker is collaboration. Docker images can be pushed to a repository and can be pulled down to any other host to run containers from that image. Moreover Docker hub has thousands of images created by users and you can pull those images down to your hosts based on your application requirements.

Installation of Docker

As said, Docker can be installed on several types of environments. ranging from Linux, via Apple’s OSX to Microsofts Azure and Windows 10. A ready environment can be obtained from Amazon AWS, Google Cloud Platform, Microsoft Azure, and a number of independent cloud providers like Digital Ocean and Rackspace. This tutorial will show how to install Docker and optionally Docker Compose on Debian and Redhat Enterprise based Linux Distributions.

RHEL based:

STEP 3: Create a Docker group to prevent use of the root user.

Debian based:

#The group docker should be created during installation, but can be done like this
sudo groupadd docker
#add the users that manage the docker containers to the group
sudo adduser $USER docker

RHEL based:

#The group docker should be created during installation, but can be done like this
sudo groupadd docker
#add the users that manage the docker containers to the group
sudo usermod -aG docker your_username

STEP 4: Install Docker compose (optional, only in DEV environments

Docker Compose applications are easy to share with your teams. You just need to define your application with Docker Compose once and use that same configuration to run the application on other machines to save your time.

Debian based:

To install Docker compose, we need to install the python-pip package as a prerequisite before installing the docker-compose.

sudo apt-get install python-pip

After that, you are ready to install docker-compose by running the below command in your command line terminal.

#Install Docker Compose
sudo pip install docker-compose

RHEL based:

On RedHat based systems, you will need to install epel-release and php-pip

sudo yum install -y epel-release python-pip

After that, you are ready to install docker-compose by running the below command in your command line terminal.

#Install Docker Compose
sudo pip install docker-compose

To run docker-compose successfully you will need to upgrade the php packages.

sudo yum upgrade python*

Now you have successfully installed docker-compose, docopt, requests, texttable and few other packages, and are able to compose docker contained applications. You are also able to run docker containers from a non-privileged account.
Hope this helps