Install Docker on various Linux Distributions
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.
Docker, Linux, How-to, RHEL, Debian, AWS, GCP, Azure, Tutorial
50921
post-template-default,single,single-post,postid-50921,single-format-standard,select-core-1.2.1,brick-child-child-theme-ver-1.0.0,brick-theme-ver-3.4,ajax_fade,page_not_loaded,smooth_scroll,side_menu_slide_from_right,vertical_menu_enabled,vertical_menu_left,vertical_menu_width_290,wpb-js-composer js-comp-ver-6.4.1,vc_responsive
Install Docker

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.

image

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.

 

Step 1: Add the repository

 

Debian based:

# docker requires apt-transport-https
sudo apt-get install apt-transport-https -y
# get the docker key for the docker registry
sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
# add the repository
sudo echo "deb https://apt.dockerproject.org/repo debian-jessie main" | \
sudo tee /etc/apt/sources.list.d/docker.list

RHEL based:

$ sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF

 

STEP 2: Install the service on your Linux machine.

 

Debian based:

# Install the Docker engine
sudo apt-get update && sudo apt-get -y install docker-engine
# Start the docker service
sudo service docker start

RHEL based:

#Install the Docker engine
sudo yum install docker-engine
# Start the docker service
sudo service docker start

 

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


Your Data, Your Responsibility, Our Business