{"id":5207,"date":"2021-03-18T10:18:01","date_gmt":"2021-03-18T10:18:01","guid":{"rendered":"https:\/\/linuxways.net\/?p=5207"},"modified":"2021-03-18T10:18:01","modified_gmt":"2021-03-18T10:18:01","slug":"how-to-install-and-use-docker-compose-on-centos-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-install-and-use-docker-compose-on-centos-8\/","title":{"rendered":"How to Install and Use Docker Compose on CentOS 8"},"content":{"rendered":"<p>Docker-decompose tool is commonly used to configure multiple container-based Docker applications. Let\u2019s we can say that Docker-compose is a command-line tool that helps to deploy multiple containers and Docker applications by using a just single command. Using the Docker-compose you can include the Docker containers into a docker-compose.yml file and mention all container services or configurations that are necessary for an application. This tool can be used in the development, testing, and production environment, apart from all of these facts it also helps in Continuous Integration workflow.<\/p>\n<p>In this article, we are installing the Docker-compose on CentOS 8 system. We will describe how you can use and configure it on your system through the command-line.<\/p>\n<h2><strong>Installation of Docker-decompose on CentOS 8<\/strong><\/h2>\n<p>Follow the below-mentioned steps to install the Docker-compose on your CentOS 8 system. The docker-compose can be installed on CentOS 8 by using the following two different ways:<\/p>\n<h2><strong>Method 01: Install Docker-compose using Python-pip tool<\/strong><\/h2>\n<p>Docker-compose can be installed on CentOS 8 system by using the python-pip tool. Use the following commands, if you want to install Docker-decompose through this method:<\/p>\n<pre>$ sudo yum install epel-release<\/pre>\n<pre>$ sudo yum install python-pip<\/pre>\n<pre># pip install docker-compose<\/pre>\n<pre># docker-compose --version<\/pre>\n<h2><strong>Method 02: Install Docker-compose from the GitHub repository<\/strong><\/h2>\n<p>To install Docker-decompose by using the curl command, you need to execute the following command to install curl on CentOS 8 if it is not already installed:<\/p>\n<pre>$ sudo dnf install curl -y<\/pre>\n<p>Now, download the Docker-compose binary from GitHub by using the curl command as follows:<\/p>\n<pre>$ sudo curl -L \"https:\/\/github.com\/docker\/compose\/releases\/download\/1.27.4\/docker-compose-$(uname -s)-$(uname -m)\" -o \/usr\/local\/bin\/docker-compose<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1094\" height=\"261\" class=\"wp-image-5208\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-284.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-284.png 1094w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-284-300x72.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-284-1024x244.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-284-768x183.png 768w\" sizes=\"auto, (max-width: 1094px) 100vw, 1094px\" \/><\/p>\n<p>Use the below-mentioned command to set permissions on a binary executable file:<\/p>\n<pre>$ sudo chmod +x \/usr\/local\/bin\/docker-compose<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1079\" height=\"115\" class=\"wp-image-5209\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-285.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-285.png 1079w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-285-300x32.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-285-1024x109.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-285-768x82.png 768w\" sizes=\"auto, (max-width: 1079px) 100vw, 1079px\" \/><\/p>\n<p>To show the Docker-compose version which is installed on your CentOS 8 system, type the following command:<\/p>\n<pre>$ docker-compose \u2013version<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"869\" height=\"114\" class=\"wp-image-5210\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-286.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-286.png 869w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-286-300x39.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-286-768x101.png 768w\" sizes=\"auto, (max-width: 869px) 100vw, 869px\" \/><\/p>\n<p>Now, the Docker-compose has been successfully installed on CentOS 8. In the rest article, we are explaining some set of commands that will help you in using the docker-compose tool.<\/p>\n<h2><strong>How to use Docker-compose on CentOS 8?<\/strong><\/h2>\n<p>All configurations about the containers-based services and container images are defined in the \u2018docker-compose.yml\u2019 file. Here, we are pulling container images of WordPress and MySQL by using the following commands:<\/p>\n<pre>$ sudo docker pull wordpress<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1143\" height=\"761\" class=\"wp-image-5211\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-287.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-287.png 1143w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-287-300x200.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-287-1024x682.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-287-768x511.png 768w\" sizes=\"auto, (max-width: 1143px) 100vw, 1143px\" \/><\/p>\n<pre>$ sudo docker pull mysql<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1134\" height=\"549\" class=\"wp-image-5212\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-288.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-288.png 1134w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-288-300x145.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-288-1024x496.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-288-768x372.png 768w\" sizes=\"auto, (max-width: 1134px) 100vw, 1134px\" \/><\/p>\n<pre>$ sudo docker image ls<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1096\" height=\"170\" class=\"wp-image-5213\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-289.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-289.png 1096w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-289-300x47.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-289-1024x159.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-289-768x119.png 768w\" sizes=\"auto, (max-width: 1096px) 100vw, 1096px\" \/><\/p>\n<p>Now, create a new directory with the name \u2018wordpress-site\u2019 and navigate into it as follows:<\/p>\n<pre>$ mkdir wordpress-site<\/pre>\n<pre>$ cd wordpress-site\/<\/pre>\n<p>Here, create a docker-compose file \u2018docker-compose.yml\u2019 and paste the following code in this file:<\/p>\n<pre>version: '3.0'\r\n\r\n\r\n\r\n\r\nservices:\r\n\r\n\u00a0\u00a0webserver:\r\n\r\n\u00a0\u00a0\u00a0\u00a0image: wordpress\r\n\r\n\u00a0\u00a0\u00a0\u00a0container_name: wp_web\r\n\r\n\u00a0\u00a0\u00a0\u00a0ports:\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0- 8080:80\r\n\r\n\u00a0\u00a0\u00a0\u00a0links:\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0- dbserver:mysql\r\n\r\n\u00a0\u00a0\u00a0\u00a0environment:\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0WORDPRESS_DB_PASSWORD: 6zcznAEjLWp79P\r\n\r\n\u00a0\u00a0dbserver:\r\n\r\n\u00a0\u00a0\u00a0\u00a0image: mysql:latest\r\n\r\n\u00a0\u00a0\u00a0\u00a0container_name: wp_db\r\n\r\n\u00a0\u00a0\u00a0\u00a0environment:\r\n\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0MYSQL_ROOT_PASSWORD: 6zcznAEjLWp79P<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1201\" height=\"651\" class=\"wp-image-5214\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-290.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-290.png 1201w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-290-300x163.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-290-1024x555.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-290-768x416.png 768w\" sizes=\"auto, (max-width: 1201px) 100vw, 1201px\" \/><\/p>\n<p>In the above file, two different container services are defined such as \u2018webserver\u2019 and \u2018dbserver\u2019. We have also defined container images and then mentioned the WordPress and dbserver passwords.<\/p>\n<p>Now, deploy these containers by running the below-mentioned command as the root user:<\/p>\n<pre># docker-compose up<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1188\" height=\"670\" class=\"wp-image-5215\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-291.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-291.png 1188w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-291-300x169.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-291-1024x578.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/03\/word-image-291-768x433.png 768w\" sizes=\"auto, (max-width: 1188px) 100vw, 1188px\" \/><\/p>\n<p>Now, browser the WordPress site URL.<\/p>\n<pre><a href=\"\/de\/blank\/\">http:\/\/{docker_host_ip}:8080<\/a><\/pre>\n<p>To start and stop the containers, use the following commands respectively:<\/p>\n<pre># docker-compose start<\/pre>\n<pre># docker-compose stop<\/pre>\n<p>To explore more about the Docker-compose usage, use the following command:<\/p>\n<pre>$ docker-compose --help<\/pre>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>We have elaborated in this article on how to install and use the Docker-compose on CentOS 8 system. By using the Docker-compose, you can deploy multiple Docker applications with container services through a single command. Visit more details related to Docker-compose through the above help guide.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Docker-decompose tool is commonly used to configure multiple container-based Docker applications. Let\u2019s we can say that Docker-compose is a command-line tool that helps to deploy multiple containers and&hellip;<\/p>","protected":false},"author":1,"featured_media":5267,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[93,232],"class_list":["post-5207","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-centos-8","tag-docker-compose"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=5207"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5207\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/5267"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=5207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=5207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=5207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}