{"id":157,"date":"2017-03-17T00:00:00","date_gmt":"2017-03-17T04:00:00","guid":{"rendered":"http:\/\/www.dev-notes.com\/blog\/2017\/03\/17\/install-local-docker-and-docker-compose-on-centos-7\/"},"modified":"2018-03-11T21:44:19","modified_gmt":"2018-03-12T01:44:19","slug":"install-local-docker-and-docker-compose-on-centos-7","status":"publish","type":"post","link":"https:\/\/www.dev-notes.com\/blog\/2017\/03\/17\/install-local-docker-and-docker-compose-on-centos-7\/","title":{"rendered":"Install local docker and docker-compose on CentOS 7"},"content":{"rendered":"<p>Configure the docker repository with yum<\/p>\n<pre class=\"code\">$ sudo tee \/etc\/yum.repos.d\/docker.repo &lt;&lt;-'EOF' &gt; [dockerrepo]\r\n&gt; name=Docker Repository\r\n&gt; baseurl=https:\/\/yum.dockerproject.org\/repo\/main\/centos\/7\/\r\n&gt; enabled=1\r\n&gt; gpgcheck=1\r\n&gt; gpgkey=https:\/\/yum.dockerproject.org\/gpg\r\n&gt; EOF\r\n<\/pre>\n<p>Install and start local docker<\/p>\n<pre class=\"code\">$ sudo yum install docker-engine\r\n$ sudo systemctl enable docker.service\r\n$ sudo systemctl start docker\r\n<\/pre>\n<p>Run a sanity check to see if docker is working properly<\/p>\n<pre class=\"code\">$ sudo docker run --rm hello-world\r\nUnable to find image 'hello-world:latest' locally\r\nlatest: Pulling from library\/hello-world\r\nc04b14da8d14: Pull complete \r\nDigest: sha256:0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9\r\nStatus: Downloaded newer image for hello-world:latest\r\n\r\nHello from Docker!\r\nThis message shows that your installation appears to be working correctly.\r\n\r\nTo generate this message, Docker took the following steps:\r\n 1. The Docker client contacted the Docker daemon.\r\n 2. The Docker daemon pulled the \"hello-world\" image from the Docker Hub.\r\n 3. The Docker daemon created a new container from that image which runs the\r\n    executable that produces the output you are currently reading.\r\n 4. The Docker daemon streamed that output to the Docker client, which sent it\r\n    to your terminal.\r\n\r\nTo try something more ambitious, you can run an Ubuntu container with:\r\n $ docker run -it ubuntu bash\r\n\r\nShare images, automate workflows, and more with a free Docker Hub account:\r\n https:\/\/hub.docker.com\r\n\r\nFor more examples and ideas, visit:\r\n https:\/\/docs.docker.com\/engine\/userguide\/\r\n<\/pre>\n<p>To allow the user to run docker without sudo, create a &#8220;docker&#8221; group and add yourusername to it.<\/p>\n<pre class=\"code\">$ sudo groupadd docker\r\n$ sudo usermod -aG docker yourusername\r\n<\/pre>\n<p>Log out and log back in for the group changes to go into effect. Try it out:<\/p>\n<pre class=\"code\">$ docker run --rm hello-world\r\n<\/pre>\n<p>Enable docker to be run after reboot<\/p>\n<pre class=\"code\">$ sudo systemctl enable docker\r\n<\/pre>\n<p>Install docker-compose<\/p>\n<pre class=\"code\">$ sudo -i\r\n# curl -L https:\/\/github.com\/docker\/compose\/releases\/download\/1.9.0\/docker-compose-`uname -s`-`uname -m` &gt; \/usr\/local\/bin\/docker-compose\r\n  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\r\n                                 Dload  Upload   Total   Spent    Left  Speed\r\n100   600    0   600    0     0   2848      0 --:--:-- --:--:-- --:--:--  2870\r\n100 7857k  100 7857k    0     0  15.5M      0 --:--:-- --:--:-- --:--:-- 15.5M\r\n# chmod +x \/usr\/local\/bin\/docker-compose\r\n# exit\r\n$ logout\r\n<\/pre>\n<p>Check that docker is running<\/p>\n<pre class=\"code\">$ docker ps -a\r\nCONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                      NAMES\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This article will show how to install local docker and docker-compose on CentOS 7.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[33,32,28],"tags":[],"class_list":["post-157","post","type-post","status-publish","format-standard","hentry","category-centos","category-docker","category-linux"],"_links":{"self":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/comments?post=157"}],"version-history":[{"count":1,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/157\/revisions"}],"predecessor-version":[{"id":161,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/posts\/157\/revisions\/161"}],"wp:attachment":[{"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/media?parent=157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/categories?post=157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dev-notes.com\/blog\/wp-json\/wp\/v2\/tags?post=157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}