{"id":7020,"date":"2017-09-25T08:08:31","date_gmt":"2017-09-25T00:08:31","guid":{"rendered":"http:\/\/rmohan.com\/?p=7020"},"modified":"2017-09-25T08:08:31","modified_gmt":"2017-09-25T00:08:31","slug":"install-docker-ce-on-centos-7","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7020","title":{"rendered":"Install docker ce on centos 7"},"content":{"rendered":"<p>Installing Docker On CentOS 7 \/ RHEL 7<\/p>\n<p>Docker is a container virtualization technology that has gained widespread popularity in recent times; it offers a more efficient way to deploy the application. With Docker, the applications reside inside the container on top of the Linux operating system. Docker uses Kernel features such as cgroups and namespace to allow an independent container to run on single os instance.<\/p>\n<p>Install from Docker (Official):<br \/>\nDocker is now available in two editions,<\/p>\n<p>Community Edition (CE)<br \/>\nEnterprise Edition (EE)<br \/>\nHere, we will install Docker Comunity Edition (CE).<\/p>\n<p>Uninstall older versions of Dockers, named \u201cdocker\u201d or \u201cdocker-engine\u201d along with associated dependencies.<\/p>\n<p># yum  -y remove  docker-common docker container-selinux docker-selinux docker-engine<br \/>\nDo not worry about the contents inside \/var\/lib\/docker\/, all will be preserved.<\/p>\n<p>The Docker Comunity package is now called \u201cdocker-ce\u201c. Let\u2019s add the CE repository for docker installation.<\/p>\n<p># yum -y install  wget<br \/>\n# wget https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo -O \/etc\/yum.repos.d\/docker-ce.repo<br \/>\nInstall the latest version of Docker CE using the following command.<\/p>\n<p># yum -y install docker-ce<\/p>\n<p># yum -y install docker<br \/>\nWorking with Docker:<br \/>\nNow you have Docker installed onto your machine, start the Docker service in case if it is not started automatically after the installation<\/p>\n<p># systemctl start docker.service<\/p>\n<p># systemctl enable docker.service<\/p>\n<p>Step 1 | Remove Old Versions<\/p>\n<p>$ sudo yum remove docker docker-common docker-selinux docker-engine<br \/>\nStep 2 | Install Required Packages<\/p>\n<p>$ sudo yum install -y yum-utils device-mapper-persistent-data lvm2<br \/>\nStep 3 | Setup the Docker CE Repository<\/p>\n<p>$ sudo yum-config-manager &#8211;add-repo https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo<br \/>\nStep 4 | Update the Packages<\/p>\n<p>$ sudo yum update<br \/>\nStep 5 |Install specific version (Production recommended)<\/p>\n<p>$ sudo yum list docker-ce.x86_64  &#8211;showduplicates | sort -r<\/p>\n<p>Loaded plugins: amazon-id, rhui-lb, search-disabled-repos<br \/>\ndocker-ce.x86_64            17.06.0.ce-1.el7.centos             docker-ce-stable<br \/>\ndocker-ce.x86_64            17.03.2.ce-1.el7.centos             docker-ce-stable<br \/>\ndocker-ce.x86_64            17.03.1.ce-1.el7.centos             docker-ce-stable<br \/>\ndocker-ce.x86_64            17.03.0.ce-1.el7.centos             docker-ce-stable<br \/>\nAvailable Packages<\/p>\n<p>$ sudo yum install docker-ce-<VERSION><br \/>\nStep 6 | Install through respository<\/p>\n<p>$ sudo yum install docker-ce<br \/>\nStep 7 | Start Docker<\/p>\n<p>$ sudo systemctl start docker<br \/>\nStep 8 | Verify the Installation<\/p>\n<p>$ sudo docker run hello-world<\/p>\n<p>Change default Image and Container location in Docker <\/p>\n<p>What to do if you have existing containers and images?<\/p>\n<p>If you want the existing containers and images to be migrated to the new location, don\u2019t reload the service daemon and start the docker service, right after modifying docker.conf, move the existing data in \/var\/lib\/docker to the new location. And create a symlink. <\/p>\n<p>Note: I have not tried the following since there was no need for me to keep existing containers and images. But these steps should work; If you are facing any trouble or aware of any alternative method please comment. I will then modify the post. Please take a backup before venturing further. <\/p>\n<p># cp \u2013rp \/var\/lib\/docker \/mnt\/new_volume<br \/>\n# ln -s \/mnt\/new_volume \/var\/lib\/docker<br \/>\nAfter this reload daemon and start docker service,<\/p>\n<p># sudo systemctl daemon-reload<br \/>\n# sudo systemctl start docker <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Installing Docker On CentOS 7 \/ RHEL 7<\/p>\n<p>Docker is a container virtualization technology that has gained widespread popularity in recent times; it offers a more efficient way to deploy the application. With Docker, the applications reside inside the container on top of the Linux operating system. Docker uses Kernel features such as cgroups and [&#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\/7020"}],"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=7020"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7020\/revisions"}],"predecessor-version":[{"id":7021,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7020\/revisions\/7021"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7020"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7020"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7020"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}