{"id":968,"date":"2019-04-22T18:52:35","date_gmt":"2019-04-22T10:52:35","guid":{"rendered":"http:\/\/jrblog.pentaidea.com\/john\/2019\/04\/22\/quick-start-to-install-docker-and-docker-compose-on-centos\/"},"modified":"2019-04-22T18:52:35","modified_gmt":"2019-04-22T10:52:35","slug":"quick-start-to-install-docker-and-docker-compose-on-centos","status":"publish","type":"post","link":"https:\/\/john.pentaidea.com\/?p=968","title":{"rendered":"Quick start to install Docker and Docker-compose on Linux"},"content":{"rendered":"<p><span style=\"font-weight: bold\">CentOS<\/span><\/p>\n<pre><code>#&nbsp;(optional) remove old\nsudo yum remove -y docker \\\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; docker-ce-cli \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-client \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-client-latest \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-common \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-latest \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-latest-logrotate \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-logrotate \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-selinux \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-engine-selinux \\\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;docker-engine\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n# Docker&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\nsudo yum install -y yum-utils \\\n&nbsp;&nbsp;device-mapper-persistent-data \\\n&nbsp;&nbsp;lvm2\n&nbsp;&nbsp;\nsudo yum-config-manager \\\n&nbsp;&nbsp;&nbsp;&nbsp;--add-repo \\\n&nbsp;&nbsp;&nbsp;&nbsp;https:\/\/download.docker.com\/linux\/centos\/docker-ce.repo\n&nbsp;&nbsp;&nbsp;&nbsp;\nsudo yum install -y docker-ce\n\n\nsudo systemctl start docker\nsudo systemctl enable docker&nbsp; # start docker at boot up\n\n# (optional) Verify\nsudo docker run hello-world\n\n<\/code><\/pre>\n<p><span style=\"font-weight: bold\">Install docker-compose<\/span><\/p>\n<pre><code># Dcoker-compose\nsudo curl -L &quot;https:\/\/github.com\/docker\/compose\/releases\/download\/1.24.0\/docker-compose-$(uname -s)-$(uname -m)&quot; -o \/usr\/local\/bin\/docker-compose\nsudo chmod +x \/usr\/local\/bin\/docker-compose\n\n\n# (optional) Verify\ndocker-compose --version\n<\/code><\/pre>\n<p><span style=\"font-weight: bold\">Advenced<\/span><\/p>\n<pre><code># Move fat docker to other folder with symlink - Linux (bash)\nsudo systemctl stop docker\nsudo mv \/var\/lib\/docker \/data\/.\nsudo ln -s \/data\/docker \/var\/lib\/docker\nsudo systemctl start docker\n\n# Move fat docker to other folder with symlink - Windows (Powershell)\nmove C:\\ProgramData\\docker\\* D:\\ProgramData\\docker\ncmd \/c mklink \/d C:\\ProgramData\\docker D:\\ProgramData\\docker\n\n\n# Add default Log rotation\nsudo bash -c &apos;cat &gt;&gt; \/etc\/docker\/daemon.json&apos; &lt;&lt; EOF\n{\n&nbsp;&nbsp;&quot;log-driver&quot;: &quot;json-file&quot;,\n&nbsp;&nbsp;&quot;log-opts&quot;: {\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;max-size&quot;: &quot;10m&quot;,\n&nbsp;&nbsp;&nbsp;&nbsp;&quot;max-file&quot;: &quot;512&quot;\n&nbsp;&nbsp;}\n}\nEOF\nsudo systemctl daemon-reload\nsudo systemctl restart docker\n\n# Execute docker without sudo\nsudo groupadd docker\nsudo usermod -aG docker $USER\n#&gt; Re-login to apply\n\n# Show other docker version\nyum list docker-ce --showduplicates | sort -r\n\n# Restart&nbsp;\n## daemon\nsudo systemctl daemon-reload\n## docker service\nsudo systemctl restart docker.service\n## docker\nsudo systemctl restart docker\n\n# Remove stuff\ndocker container prune&nbsp;&nbsp; &nbsp;# Remove all stopped containers\ndocker volume prune &nbsp;&nbsp; &nbsp;# Remove all unused volumes\ndocker image prune &nbsp;&nbsp; &nbsp;# Remove unused images\ndocker system prune &nbsp;&nbsp; &nbsp;# All of the above, in this order: containers, volumes, images\ndocker ps -a -q | % { docker rm $_ }&nbsp;&nbsp; &nbsp; # Remove container with PowerShell\ndocker rm $(docker ps -a -q)&nbsp;&nbsp; &nbsp; #&nbsp;Remove container with Bash\ndocker volume rm $(docker volume ls -f dangling=true -q)\n\n<\/code><\/pre>\n<p><a href=\"https:\/\/docs.docker.com\/install\/linux\/docker-ce\/ubuntu\/\">Ubuntu<\/a><\/p>\n<pre><code># (optional) Remove old\nsudo apt-get remove -y docker-ce docker-ce-cli docker docker-engine docker.io containerd runc\n\n# Setting up\nsudo apt-get update\nsudo apt-get install -y \\\n&nbsp;&nbsp;&nbsp;&nbsp;apt-transport-https \\\n&nbsp;&nbsp;&nbsp;&nbsp;ca-certificates \\\n&nbsp;&nbsp;&nbsp;&nbsp;curl \\\n&nbsp;&nbsp;&nbsp;&nbsp;gnupg-agent \\\n&nbsp;&nbsp;&nbsp;&nbsp;software-properties-common\n\ncurl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo apt-key add -\n\n## (optional) Verify fingerprint&nbsp;\nsudo apt-key fingerprint 0EBFCD88\n\nsudo add-apt-repository \\\n&nbsp;&nbsp;&nbsp;&quot;deb [arch=amd64] https:\/\/download.docker.com\/linux\/ubuntu \\\n&nbsp;&nbsp;&nbsp;$(lsb_release -cs) \\\n&nbsp;&nbsp;&nbsp;stable&quot;\n\n# Install latest\nsudo apt-get update\nsudo apt-get install -y docker-ce docker-ce-cli containerd.io\n\n## (optional) Install other version.&nbsp; PS.&quot;18.09 no need to install docker-ce-cli&quot;\napt-cache madison docker-ce\nsudo apt-get install docker-ce=&lt;VERSION_STRING&gt; docker-ce-cli=&lt;VERSION_STRING&gt; containerd.io\n\n# (optional) Verify\nsudo docker run hello-world\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>CentOS<\/p>\n<\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-968","post","type-post","status-publish","format-standard","hentry","category-tech"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Quick start to install Docker and Docker-compose on Linux - John&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/john.pentaidea.com\/?p=968\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Quick start to install Docker and Docker-compose on Linux - John&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"CentOS\" \/>\n<meta property=\"og:url\" content=\"https:\/\/john.pentaidea.com\/?p=968\" \/>\n<meta property=\"og:site_name\" content=\"John&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2019-04-22T10:52:35+00:00\" \/>\n<meta name=\"author\" content=\"jj\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"jj\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/john.pentaidea.com\/?p=968\",\"url\":\"https:\/\/john.pentaidea.com\/?p=968\",\"name\":\"Quick start to install Docker and Docker-compose on Linux - John&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/john.pentaidea.com\/#website\"},\"datePublished\":\"2019-04-22T10:52:35+00:00\",\"dateModified\":\"2019-04-22T10:52:35+00:00\",\"author\":{\"@id\":\"https:\/\/john.pentaidea.com\/#\/schema\/person\/3d2e5980a7d3023e93b91d668d2a4a4f\"},\"breadcrumb\":{\"@id\":\"https:\/\/john.pentaidea.com\/?p=968#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/john.pentaidea.com\/?p=968\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/john.pentaidea.com\/?p=968#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/john.pentaidea.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Quick start to install Docker and Docker-compose on Linux\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/john.pentaidea.com\/#website\",\"url\":\"https:\/\/john.pentaidea.com\/\",\"name\":\"John's Blog\",\"description\":\"\u4e16\u754c\u56e0\u601d\u7dd2\u800c\u8907\u96dc, \u4eba\u56e0\u5922\u60f3\u800c\u5049\u5927\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/john.pentaidea.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/john.pentaidea.com\/#\/schema\/person\/3d2e5980a7d3023e93b91d668d2a4a4f\",\"name\":\"jj\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/john.pentaidea.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a685414cd92056415bc823b5cfbbf95a44a98df88d8c040b18613724c1c0724b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a685414cd92056415bc823b5cfbbf95a44a98df88d8c040b18613724c1c0724b?s=96&d=mm&r=g\",\"caption\":\"jj\"},\"sameAs\":[\"https:\/\/john.pentaidea.com\"],\"url\":\"https:\/\/john.pentaidea.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Quick start to install Docker and Docker-compose on Linux - John&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/john.pentaidea.com\/?p=968","og_locale":"en_US","og_type":"article","og_title":"Quick start to install Docker and Docker-compose on Linux - John&#039;s Blog","og_description":"CentOS","og_url":"https:\/\/john.pentaidea.com\/?p=968","og_site_name":"John&#039;s Blog","article_published_time":"2019-04-22T10:52:35+00:00","author":"jj","twitter_card":"summary_large_image","twitter_misc":{"Written by":"jj","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/john.pentaidea.com\/?p=968","url":"https:\/\/john.pentaidea.com\/?p=968","name":"Quick start to install Docker and Docker-compose on Linux - John&#039;s Blog","isPartOf":{"@id":"https:\/\/john.pentaidea.com\/#website"},"datePublished":"2019-04-22T10:52:35+00:00","dateModified":"2019-04-22T10:52:35+00:00","author":{"@id":"https:\/\/john.pentaidea.com\/#\/schema\/person\/3d2e5980a7d3023e93b91d668d2a4a4f"},"breadcrumb":{"@id":"https:\/\/john.pentaidea.com\/?p=968#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/john.pentaidea.com\/?p=968"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/john.pentaidea.com\/?p=968#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/john.pentaidea.com\/"},{"@type":"ListItem","position":2,"name":"Quick start to install Docker and Docker-compose on Linux"}]},{"@type":"WebSite","@id":"https:\/\/john.pentaidea.com\/#website","url":"https:\/\/john.pentaidea.com\/","name":"John's Blog","description":"\u4e16\u754c\u56e0\u601d\u7dd2\u800c\u8907\u96dc, \u4eba\u56e0\u5922\u60f3\u800c\u5049\u5927","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/john.pentaidea.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/john.pentaidea.com\/#\/schema\/person\/3d2e5980a7d3023e93b91d668d2a4a4f","name":"jj","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/john.pentaidea.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a685414cd92056415bc823b5cfbbf95a44a98df88d8c040b18613724c1c0724b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a685414cd92056415bc823b5cfbbf95a44a98df88d8c040b18613724c1c0724b?s=96&d=mm&r=g","caption":"jj"},"sameAs":["https:\/\/john.pentaidea.com"],"url":"https:\/\/john.pentaidea.com\/?author=1"}]}},"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=\/wp\/v2\/posts\/968","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=968"}],"version-history":[{"count":0,"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=\/wp\/v2\/posts\/968\/revisions"}],"wp:attachment":[{"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/john.pentaidea.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}