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
Postfix is a free and open source MTA (Mail Tra...
Table of contents Event-driven and publish-subscr...
This article mainly introduces the implementation...
When it comes to tool-type websites, we first hav...
Implemented according to the online tutorial. zab...
Table of contents introduce Key Features Effect d...
1. Simple configuration of nginx's dynamic an...
Today I suddenly thought that the styles of check ...
1. Download First of all, I would like to recomme...
Add secure_file_priv = ' '; then run cmd ...
1. MIME: Multipurpose Internet Mail Extensions Th...
1. Enter the host machine of the docker container...
Today I got familiar with the mouse zooming effect...
If you’re looking for inspiration for columnar web...
Hello everyone, I am Tony, a teacher who only tal...