Docker Compose Docker Compose divides the managed containers into three layers: project, service, and container. All files in the directory where Docker Compose is running (docker-compose.yml, extends files or environment variable files, etc.) form a project. If no special project name is specified, the current directory name is used. A project can contain multiple services, and each service defines the image, parameters, and dependencies of the container running. A service can include multiple container instances. Docker Compose does not solve the problem of load balancing, so other tools are needed to achieve service discovery and load balancing. Install Docker Compose Get docker-compose-linux-x86_64 and put it in the /bin directory, make a soft link and add executable permissions chmod +x docker-compose-linux-x86_64 ln -s docker-compose-linux-x86_64 docker-compose Import haproxy and nginx to facilitate subsequent load balancing tests docker load -i haproxy docker load -i nginx Write the compose configuration file in /tmp/ [root@foundation50 compose]#vim docker-compose.yml Create and install the httpd service and start the httpd file in the web1 httpd service [root@foundation50 compose]#vim web1/Dockerfile FROM rhel7:v1 EXPOSE 80 RUN yum install -y httpd ADD index.html /var/www/html CMD ["/usr/sbin/httpd","-D","FOREGROUND"] Create a haproxy.cfg configuration file in haproxy Check View haproxy statistics Visit 172.25.50.1 Health Check Shutdown web3 docker swarm Prepare three virtual machines Install Docker on server1, server2, and server3 and start the service You need to run docker swarm init on one node, and then run the join command on other nodes. [root@server1 ~]# docker swarm init [root@server2~]#docker swarm join \ >--tokenSWMTKN-1-51igcdpg4cbgaokq535qis01osel396of153sdlp8k0ljn0rou-2m9sltwkc4uq1vfmp79ous0e4 \ > 172.25.50.2:2377 This node joined a swarm as a worker. Check the node status on server1 Nginx has been imported before, and then flsak is imported to three machines [root@server1 ~]# docker load -i flask.tar [root@server2 ~]# docker load -i flask.tar [root@server3 ~]# docker load -i flask.tar To distinguish the load balancing of different backends, a statement showing the host name is written in Python and imported into flask and os Open the flask image and put the demo.py script under root submit [root@server1 python]# docker commit vm1 python:demo Create a cluster named flask, start three backend service nodes, and read the demo.py script under Python test [root@foundation50 docker]# for i in {1..10}:do curl -w "\n" http://172.25.50.1;done Because there are three servers, polling is completed every three times, achieving load balancing Docker swarm visual web monitoring interface Import the image and create [root@server1 ~]# docker load -i visualizer.tar [root@server1 ~]# docker service create --name=viz --publish=8080:8080/tcp --constrain=node.role==manager --mount=type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock dockersamples/visualizer View monitoring page The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. |
<<: How to modify the initial password of MySQL on MAC
>>: Summary of four ways to loop through an array in JS
In the previous article, we introduced how to for...
React Hooks is a new feature introduced in React ...
Table of contents 1. Introduction 2. Preparation ...
Because I wrote the word transition incorrectly i...
Table of contents Overview (Loop Mode - Common) D...
In MySQL, most indexes (such as PRIMARY KEY, UNIQ...
1. Rounded border: CSS CodeCopy content to clipbo...
MySQL supports many data types, and choosing the ...
I have done some research on "embedding non-...
<p><b>This is bold font</b></...
Through the brief introduction in the previous tw...
Method 1: Use the SET PASSWORD command mysql> ...
Table of contents 1. Grammar 2. Examples 3. Other...
Table of contents accomplish: Summarize: Not much...
Let's first look at the MySQL official docume...