Redhat 7 Docker

In my last article I shared the steps to configure or build ceph storage cluster in Openstack.Now in this article I will share the steps to install docker on CentOS 7 or RHEL 7 Linux and to configure thin provisioning storage for Docker, Now Docker is one of the most common container solution, but it's not the only container solution. Docker is kinda dumb about how they structure their yum repos and this confuses people all the time. Proof: look at the directories in the rhel/7 directory compared to the ones in the centos/7 directory. The rhel directory only contains s390x and source, and the CentOS one has an x8664 directory with the packages and repo metadata. The objective is to install Docker engine on Redhat 7 Linux using native docker script. Internet connection as well as a privileged access to your Redhat 7 Linux is required. Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command. How to enable Proxy for Docker engine with or without authentication on CentOS 7, Red Hat Enterprise Linux 7? Edit Docker configuration file. Edit /etc/sysconfig/docker file and add the below code at the bottom: a) using authentication.



For more information on Docker, visit docker.com


Description:

This instruction set will show how to build a base container image using CentOS Linux 7. This container image is the image used for many of the appcontainers images found on the docker hub.


Docker

CentOS 7 Linux Base Minimal Install - 176 MB (tags: 7)CentOS 7 Linux Base with Ansible - 229 MB (tags: ansible-7)

This container is built from centos:7, (242/295 MB Before Flatification)


Installation Steps:

Install official CentOS 7 GPG Key:


Install the Epel Repository:


Install the Remi Repository:


Modify Remi Repo to enable remi base and PHP 7.1:


Update the OS:

The following packages are also installed on the :ansible variant only


The following configuration is also set on the ansible variant only


CentOS recommended systemd fixes:


Cleanup:

Remove the contents of /var/cache/ after a yum update or yum install will save about 150MB from the image size


Redhat 7 Docker

Cleanup Locales:

Docker


Set the default Timezone to EST:


Remove Man Pages and Docs to preserve Space:


Set the Terminal CLI Prompt:

Copy the included Terminal CLI Color Scheme file to /etc/profile.d so that the terminal color will be included in all child images


Prevent the .bashrc from being executed via SSH or SCP sessions:


Set Dockerfile Runtime command:

Default command to run when lauched via docker run


Dockerfile:


Building the image from the Dockerfile:


Packaging the final image:

Because we want to make this image as light weight as possible in terms of size, the image is flattened in order to remove the docker build tree, removing any intermediary build containers from the image. In order to remove the reversion history, the image needs to be ran, and then exported/imported. Note that just saving the image will not remove the revision history, In order to remove the revision history, the running container must be exported and then re-imported.


Run the container build:

The run statement should start a detached container, however if you are attached, detach from the container

Redhat 7 Docker

CTL P + CTL Q


Export and Re-import the Container:

Note that because we started the build container with the name of centos, we will use that in the export statement instead of the container ID.


Verify:

Issuing a docker images should now show a newly saved appcontainers/centos image, which can be pushed to the docker hub.


Run the container:

Redhat 7 Docker


Dockerfile Change-log:

Docker CE is not officially supported on RHEL but if you're in a pinch, you can get the latest Docker CE installed on it.

I’ll admit, I’m not a RedHat expert. I’ve been using Debian based distros since the beginning but recently I was in a position where I had to get Docker CE installed on RedHat 7.2.

It wasn’t my position to question or attempt to persuade anyone into changing. My only task was “get the latest version of Docker CE installed on RHEL 7.x”.

Redhat 7 Docker Key

If you follow the CentOS instructions for Docker CE , chances are you got the dreaded Requires: container-selinux >= 2.9 error when trying to install CE on RedHat 7.x.

Redhat 7 Dockery

Here’s what I eventually ended up doing which worked:

This just installs a more recent version of container-selinx before installing Docker.

One thing to note is the long mirror.centos.org command. You’ll want to check the list of extra packages for the latest version of container-selinux. At the time of writing this article it was 2.33.1.

You can check by going to http://mirror.centos.org/centos/7/extras/x86_64/Packages/. Just copy the link address for the latest container-selinux and replace mine from above.

Is it safe in production?

Redhat 7 Docker Download

That’s for you and your organization to decide. It’s safe in the sense that you are pulling things down from an official CentOS repository. However…

Redhat 7 Docker Support

Since you’re pulling in a CentOS repository, that will void all support from RHEL which kind of defeats the purpose of being a RHEL subscriber, but sometimes you get handed a problem with no alternative solution.