{"id":7235,"date":"2018-02-28T10:51:19","date_gmt":"2018-02-28T02:51:19","guid":{"rendered":"http:\/\/rmohan.com\/?p=7235"},"modified":"2018-02-28T10:56:03","modified_gmt":"2018-02-28T02:56:03","slug":"docker-installation-on-rhel-7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7235","title":{"rendered":"Docker installation on RHEL 7"},"content":{"rendered":"<h2 id=\"h1-objective\">Objective<\/h2>\n<p>The objective is to install Docker engine on Redhat 7 Linux using native docker script.<\/p>\n<h2 id=\"h2-requirements\">Requirements<\/h2>\n<p>Internet connection as well as a privileged access to your Redhat 7 Linux is required.<\/p>\n<h2 id=\"h3-difficulty\">Difficulty<\/h2>\n<p>EASY<\/p>\n<h2 id=\"h4-conventions\">Conventions<\/h2>\n<ul>\n<li><b>#<\/b> &#8211; requires given command to be executed with root privileges either directly as a root user or by use of <code>sudo<\/code> command<\/li>\n<li><b>$<\/b> &#8211; given command to be executed as a regular non-privileged user<\/li>\n<\/ul>\n<h2 id=\"h5-instructions\">Instructions<\/h2>\n<h3 id=\"h5-1-install-docker\">Install docker<\/h3>\n<p>Installation of docker using a native docker script is one command, straight forward process. Before you run the below docker installation command ensure that <code>curl<\/code> package is installed on your system:<\/p>\n<p>&nbsp;<\/p>\n<p>yum\u00a0 -y remove\u00a0 docker-common docker container-selinux docker-selinux docker-engine<\/p>\n<p>&nbsp;<\/p>\n<p>yum -y install lvm2 device-mapper device-mapper-persistent-data device-mapper-event device-mapper-libs device-mapper-event-libs<\/p>\n<pre># curl --version\r\ncurl 7.29.0 (x86_64-redhat-linux-gnu)\r\n<\/pre>\n<p>Once ready, install docker using <code>curl<\/code> command which will download and execute a native docker installation script:<\/p>\n<pre># curl -sSL https:\/\/get.docker.com\/ | sh\r\n+ sh -c 'sleep 3; yum -y -q install docker-engine'\r\nwarning: \/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\r\nImporting GPG key 0x2C52609D:\r\n Userid     : \"Docker Release Tool (releasedocker) &lt;docker@docker.com&gt;\"\r\n Fingerprint: 5811 8e89 f3a9 1289 7c07 0adb f762 2157 2c52 609d\r\n From       : https:\/\/yum.dockerproject.org\/gpg\r\nIf you would like to use Docker as a non-root user, you should now consider\r\nadding your user to the \"docker\" group with something like:\r\n\r\n  sudo usermod -aG docker your-user\r\n\r\nRemember that you will have to log out and back in for this to take effect!\r\n&lt;\/docker@docker.com&gt;<\/pre>\n<h3 id=\"h5-2-enable-and-start-docker\">Enable and Start docker<\/h3>\n<p>To enable docker to start on your Redhat 7 Linux after reboot run the following command:<\/p>\n<pre># systemctl enable docker\r\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/docker.service to \/usr\/lib\/systemd\/system\/docker.service.\r\n<\/pre>\n<p>To start docker daemon run:<\/p>\n<pre># systemctl start docker\r\n<\/pre>\n<pre>\u00a0wget https:\/\/download.docker.com\/linux\/centos\/7\/x86_64\/stable\/Packages\/docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm\r\n\r\n wget https:\/\/download.docker.com\/linux\/centos\/7\/x86_64\/stable\/Packages\/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm\r\n\r\n\r\n yum install --setopt=obsoletes=0 docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm\r\n\r\n\r\n<\/pre>\n<p>[root@ip-192-168-4-100 software]# yum install &#8211;setopt=obsoletes=0 docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm<br \/>\nLoaded plugins: amazon-id, rhui-lb, search-disabled-repos<br \/>\nExamining docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm: docker-ce-17.12.1.ce-1.el7.centos.x86_64<br \/>\nMarking docker-ce-17.12.1.ce-1.el7.centos.x86_64.rpm to be installed<br \/>\nResolving Dependencies<br \/>\n&#8211;&gt; Running transaction check<br \/>\n&#8212;&gt; Package docker-ce.x86_64 0:17.12.1.ce-1.el7.centos will be installed<br \/>\n&#8211;&gt; Processing Dependency: container-selinux &gt;= 2.9 for package: docker-ce-17.12.1.ce-1.el7.centos.x86_64<br \/>\n&#8211;&gt; Processing Dependency: libltdl.so.7()(64bit) for package: docker-ce-17.12.1.ce-1.el7.centos.x86_64<br \/>\n&#8211;&gt; Running transaction check<br \/>\n&#8212;&gt; Package container-selinux.noarch 2:2.36-1.gitff95335.el7 will be installed<br \/>\n&#8212;&gt; Package libtool-ltdl.x86_64 0:2.4.2-22.el7_3 will be installed<br \/>\n&#8211;&gt; Finished Dependency Resolution<\/p>\n<p>Dependencies Resolved<\/p>\n<p>================================================================================================================================================================================================================<br \/>\nPackage Arch Version Repository Size<br \/>\n================================================================================================================================================================================================================<br \/>\nInstalling:<br \/>\ndocker-ce x86_64 17.12.1.ce-1.el7.centos \/docker-ce-17.12.1.ce-1.el7.centos.x86_64 123 M<br \/>\nInstalling for dependencies:<br \/>\ncontainer-selinux noarch 2:2.36-1.gitff95335.el7 rhui-REGION-rhel-server-extras 31 k<br \/>\nlibtool-ltdl x86_64 2.4.2-22.el7_3 rhui-REGION-rhel-server-releases 49 k<\/p>\n<p>Transaction Summary<br \/>\n================================================================================================================================================================================================================<br \/>\nInstall 1 Package (+2 Dependent packages)<\/p>\n<p>Total size: 123 M<br \/>\nTotal download size: 80 k<br \/>\nInstalled size: 123 M<\/p>\n<p>unning transaction check<br \/>\nRunning transaction test<br \/>\nTransaction test succeeded<br \/>\nRunning transaction<br \/>\nInstalling : 2:container-selinux-2.36-1.gitff95335.el7.noarch 1\/3<br \/>\nsetsebool: SELinux is disabled.<br \/>\nInstalling : libtool-ltdl-2.4.2-22.el7_3.x86_64 2\/3<br \/>\nInstalling : docker-ce-17.12.1.ce-1.el7.centos.x86_64 3\/3<br \/>\nVerifying : libtool-ltdl-2.4.2-22.el7_3.x86_64 1\/3<br \/>\nVerifying : 2:container-selinux-2.36-1.gitff95335.el7.noarch 2\/3<br \/>\nVerifying : docker-ce-17.12.1.ce-1.el7.centos.x86_64 3\/3<\/p>\n<p>Installed:<br \/>\ndocker-ce.x86_64 0:17.12.1.ce-1.el7.centos<\/p>\n<p>Dependency Installed:<br \/>\ncontainer-selinux.noarch 2:2.36-1.gitff95335.el7 libtool-ltdl.x86_64 0:2.4.2-22.el7_3<\/p>\n<p>Complete!<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>How to enable docker service<\/h2>\n<p><code>$ sudo systemctl enable docker.service<\/code><br \/>\nSample outputs:<\/p>\n<pre>Created symlink from \/etc\/systemd\/system\/multi-user.target.wants\/docker.service to \/usr\/lib\/systemd\/system\/docker.service.<\/pre>\n<h2>How to start\/stop\/restart docker service on CentOS7\/RHEL7<\/h2>\n<p><code>$ sudo systemctl start docker.service ## <kbd>&lt;-- Start docker<\/kbd> ##<br \/>\n$ sudo systemctl stop docker.service ## <kbd>&lt;-- Stop docker<\/kbd> ##<br \/>\n$ sudo systemctl restart docker.service ## <kbd>&lt;-- Restart docker<\/kbd> ##<br \/>\n$ sudo systemctl status docker.service ## <kbd>&lt;-- Get status of docker<\/kbd> ##<\/code><\/p>\n<pre><strong>\u00a0# verify operation<\/strong> \r\ndocker ps -a \r\ndocker images \r\ndocker version \r\ndocker info \r\n\r\n\r\n<\/pre>\n<p><strong>Process below works fine for AWS RedHat 7.X instance:<\/strong><\/p>\n<pre><code> 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\r\n yum install -y yum-utils device-mapper-persistent-data lvm2\r\n yum-config-manager --add-repo https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo\r\n yum-config-manager --enable docker-ce-edge\r\n yum makecache fast\r\n yum -y --enablerepo=rhui-REGION-rhel-server-extras install container-selinux\r\n yum -y install docker-ce\r\n<\/code>\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Objective <\/p>\n<p>The objective is to install Docker engine on Redhat 7 Linux using native docker script.<\/p>\n<p> Requirements <\/p>\n<p>Internet connection as well as a privileged access to your Redhat 7 Linux is required.<\/p>\n<p> Difficulty <\/p>\n<p>EASY<\/p>\n<p> Conventions # &#8211; requires given command to be executed with root privileges either directly as a root user or by use [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[82],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7235"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7235"}],"version-history":[{"count":4,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7235\/revisions"}],"predecessor-version":[{"id":7239,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7235\/revisions\/7239"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}