need: The official website's resource server certainly cannot use one instance, it needs multiple instances together, but if it continues to copy it is too slow, I wonder if I can directly use the docker image to create several identical container instances. Two docker-compose.yml files version: '3' services: micro-hcnet-website-13: image: 172.18.0.1:5000/hcnet-website-12:0.0.1-SNAPSHOT restart: on-failure ports: -8311:8211 ~ version: '3' services: micro-hcnet-website-13: image: 172.18.0.1:5000/hcnet-website-12:0.0.1-SNAPSHOT restart: on-failure ports: -8211:8211 ~ After executing docker-compse.yml Display normal startup View Container Mapping success Finally check consul Sure enough, they are all the same mapping interface. Additional knowledge: Getting started with Docker - Building multiple containers (docker-compose) Starting multiple services (containers) at a time will facilitate our operations in production practice Take haproy load balancing apache service and nginx service as an example Multi-container application of docker through compose Compose is a Docker application that allows users to define and run multiple containers. In Compose you can use YAML files to configure your application services. Then, with just one simple command, all the services you configured are created and started. Using Compose basically involves the following three steps: Define your application environment in a Dockerfile to make it replicable anywhere. Define the services that make up your application in docker-compose.yml so that they can run together in isolated environments. Finally, run docker-compose up and Compose will start and run the entire application. 1. Edit the docker-compose.yml file to specify multiple images apache: # apache service image: rhel7:v1 # parent image name expose: - 80 # Expose port volumes: # Mount volume - ./web/:/var/www/html nginx: # nginx serviceimage: nginx # parent imageexpose: - 80 # Expose port haproxy: # haproxy service image: haproxy # Parent image volumes: # Mount volume - ./haproxy:/usr/local/etc/haproxy links: # Associated container - apache - nginx ports: #Port mapping - "8080:80" expose: # Exposed service port - 80 2. Edit the haproxy configuration file global # Global configuration, log information log 127.0.0.1 local0 log 127.0.0.1 local1 notice defaults log global option httplog option dontlognull timeout connect 5000ms timeout client 50000ms timeout server 50000ms stats uri /status frontend balancer bind 0.0.0.0:80 # Listening port default_backend web_backends # Default backend backend web_backends Balance Round Robin server weba apache:80 check # The backend a apache corresponds to the content in the links in the .yml file server webb nginx:80 check Check whether the required documents are sufficient [root@foundation21 compose]# ls docker-compose.yml haproxy web [root@foundation21 compose]# pwd /tmp/docker/compose # View file affiliation [root@foundation21 compose]# tree . ├── docker-compose.yml ├── haproxy │ └── haproxy.cfg └── web └── index.html 2 directories, 3 files Execute the docker-compose up command in the cmopose directory to start multiple images at the same time To view it in a browser: haproxy implements load balancing for backend web servers The above Docker uses a single image to map to multiple ports. This is all the content that the editor shares with you. I hope it can give you a reference. I also hope that you will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed Analysis of the Selection of MySQL Common Index and Unique Index
>>: The solution of html2canvas that pictures cannot be captured normally
Aggregating data from various sources allows the ...
Table of contents Vue custom directive Custom dir...
Slow log query function The main function of slow...
What is the input type="file"? I don'...
Data backup and restore part 3, details are as fo...
Cocos Creator version: 2.3.4 Demo download: https...
Preface Recently, I encountered such a problem wh...
This article example shares the specific code of ...
MySql uses joined table queries, which may be dif...
Table of contents 1.parseInt(string, radix) 2. Nu...
Table of contents Preface Jump to APP method URL ...
In design work, I often hear designers participati...
The floating-point types supported in MySQL are F...
A Multi-Select is a UI element that lists all opt...
This article example shares the specific code of ...