Docker Compose Install Centos

2/13/2022by admin
  1. See Full List On Docs.docker.com
  2. Getting Started
  3. Ansible Install Docker Compose Centos 7
  4. Docker Compose Install Centos 6

Install Docker Compose on CentOS 7. First let’s start by ensuring your system is up-to-date. Yum clean all yum -y update. Installing Docker using YUM. Docker is included by default in the CentOS-Extras repository. To install run the following command: yum -y install docker yum -y install device-mapper device-mapper-event.

See full list on docs.docker.com. Install Docker on CentOS 6. Upgrade kernel 3.10 Check kernel version. Uname -r = 2.6.32-279.el6.x8664. Install docker-compose. Install Docker Compose. To install docker-compose, I will use the following command line, which is using curl. Note: The command is downloading version 1.25.5, downloading a different version change the number to the version is needed. Jun 22, 2020 How to install docker compose in CentOs 7? Let’s discuss how we install docker compose in CentOS 7. Before starting any installation, we update the software repositories and software packages using the following commands: yum update yum upgrade. Then, we download the current stable release of Docker Compose.

With the Docker Compose utility we can create our own environment for web development.

We will be using two Dockerfiles created on previous posts:

  • For the web server: Apache and PHP
    Docker Container: Centos 7, Apache, and PHP 7.3

  • For the database server: MySQL
    Docker Container: MySQL 8

First, we create a file named docker-compose.yml.
On that file we will define two services 'web' and 'db'

docker-compose.yml


  • The 'web' service will use the Dockerfile for our Apache/PHP container.
  • The 'db' service will use the Dockerfile for our MySQL container.
  • For the root user we are using the password 'root'. You may want to use a more secure password.
  • We also use the port 3306 to access the MySQL server from the host machine. If you already have another instance of MySQL running, you may need to use a different port. (i.e. '4001:3306')

Dockerfile for Web Server

This is the Dockerfile for the web server.


This is the Dockerfile for the database server.


Files

You can download the above files, as well as additional files as a zip file here.

Install docker compose centos 7 rpmStarted

Uncompress the zipped file, and you will have the following folder structure and files:


Now we create the containers.
Open a terminal window, navigate to the folder with the docker-compose.yml file, and type the following command.


You will see an output similar to this one (excerpts):


After the containers have finished building, we can check the logs with the following command:


Docker-compose yum install centos 7

Output (excerpts):


Install

See Full List On Docs.docker.com

Test the Containers

To test that our web and database servers are working correctly there is included a test.php file that will try to make a connection to the database.


  • As 'host' variable we can use the name of our 'db' service. We don't need to specify its IP address.
  • If you have specified a different password for the root user on the docker-compose.yml file. You would have to change it on this file as well.

Open your web browser and go to the http://localhost:4000/test.php url.

You should see the following text:

If the connection couldn't be made, an error message, indicating the reason, will be displayed instead.


After you have finished working with your containers you can stop them:


To re-start them, you would execute the docker-compose up -d specified above.

Getting Started


Remove the Containers

If you don't need the containers any more you can remove them:


Docker Compose Install Centos

Ansible Install Docker Compose Centos 7

apache-php7-mysql8.zip

Docker Compose Install Centos 6

Check the docker-compose.yml and Dockerfiles on Github here.

Comments are closed.