October 2024
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Categories

October 2024
M T W T F S S
 123456
78910111213
14151617181920
21222324252627
28293031  

Docker installation on RHEL 7

Objective

The objective is to install Docker engine on Redhat 7 Linux using native docker script.

Requirements

Internet connection as well as a privileged access to your Redhat 7 Linux is required.

Difficulty

EASY

Conventions

  • # – requires given command to be executed with root privileges either directly as a root user or by use of sudo command
  • $ – given command to be executed as a regular non-privileged user

Instructions

Install docker

Installation of docker using a native docker script is one command, straight forward process. Before you run the below docker installation command ensure that curl package is installed on your system:

 

yum  -y remove  docker-common docker container-selinux docker-selinux docker-engine

 

yum -y install lvm2 device-mapper device-mapper-persistent-data device-mapper-event device-mapper-libs device-mapper-event-libs

# curl --version
curl 7.29.0 (x86_64-redhat-linux-gnu)

Once ready, install docker using curl command which will download and execute a native docker installation script:

# curl -sSL https://get.docker.com/ | sh
+ sh -c 'sleep 3; yum -y -q install docker-engine'
warning: /var/cache/yum/x86_64/7Server/docker-main-repo/packages/docker-engine-1.12.3-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
Importing GPG key 0x2C52609D:
 Userid     : "Docker Release Tool (releasedocker) <docker@docker.com>"
 Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d
 From       : https://yum.dockerproject.org/gpg
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!
</docker@docker.com>

Enable and Start docker

To enable docker to start on your Redhat 7 Linux after reboot run the following command:

# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

To start docker daemon run:

# systemctl start docker
 wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm

 wget https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm


 yum install --setopt=obsoletes=0 docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm


[root@ip-192-168-4-100 software]# yum install –setopt=obsoletes=0 docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm
Loaded plugins: amazon-id, rhui-lb, search-disabled-repos
Examining docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm: docker-ce-17.12.1.ce-1.el7.centos.x86_64
Marking docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm to be installed
Resolving Dependencies
–> Running transaction check
—> Package docker-ce.x86_64 0:17.12.1.ce-1.el7.centos will be installed
–> Processing Dependency: container-selinux >= 2.9 for package: docker-ce-17.12.1.ce-1.el7.centos.x86_64
–> Processing Dependency: libltdl.so.7()(64bit) for package: docker-ce-17.12.1.ce-1.el7.centos.x86_64
–> Running transaction check
—> Package container-selinux.noarch 2:2.36-1.gitff95335.el7 will be installed
—> Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================================================
Installing:
docker-ce x86_64 17.12.1.ce-1.el7.centos /docker-ce-17.12.1.ce-1.el7.centos.x86_64 123 M
Installing for dependencies:
container-selinux noarch 2:2.36-1.gitff95335.el7 rhui-REGION-rhel-server-extras 31 k
libtool-ltdl x86_64 2.4.2-22.el7_3 rhui-REGION-rhel-server-releases 49 k

Transaction Summary
================================================================================================================================================================================================================
Install 1 Package (+2 Dependent packages)

Total size: 123 M
Total download size: 80 k
Installed size: 123 M

unning transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 2:container-selinux-2.36-1.gitff95335.el7.noarch 1/3
setsebool: SELinux is disabled.
Installing : libtool-ltdl-2.4.2-22.el7_3.x86_64 2/3
Installing : docker-ce-17.12.1.ce-1.el7.centos.x86_64 3/3
Verifying : libtool-ltdl-2.4.2-22.el7_3.x86_64 1/3
Verifying : 2:container-selinux-2.36-1.gitff95335.el7.noarch 2/3
Verifying : docker-ce-17.12.1.ce-1.el7.centos.x86_64 3/3

Installed:
docker-ce.x86_64 0:17.12.1.ce-1.el7.centos

Dependency Installed:
container-selinux.noarch 2:2.36-1.gitff95335.el7 libtool-ltdl.x86_64 0:2.4.2-22.el7_3

Complete!

 

 

 

How to enable docker service

$ sudo systemctl enable docker.service
Sample outputs:

Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

How to start/stop/restart docker service on CentOS7/RHEL7

$ sudo systemctl start docker.service ## <-- Start docker ##
$ sudo systemctl stop docker.service ## <-- Stop docker ##
$ sudo systemctl restart docker.service ## <-- Restart docker ##
$ sudo systemctl status docker.service ## <-- Get status of docker ##

 # verify operation 
docker ps -a 
docker images 
docker version 
docker info 


Process below works fine for AWS RedHat 7.X instance:

 yum install --setopt=obsoletes=0 docker-ce-17.03.2.ce-1.el7.centos.x86_64 docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch
 yum install -y yum-utils device-mapper-persistent-data lvm2
 yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
 yum-config-manager --enable docker-ce-edge
 yum makecache fast
 yum -y --enablerepo=rhui-REGION-rhel-server-extras install container-selinux
 yum -y install docker-ce


Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>