docker-10-docker service orchestration Compose

1 Introduction to Service Orchestration

(1) Service Orchestration
The application system of the microservice architecture generally contains several microservices, and each microservice generally deploys multiple instances. If each microservice has to be manually started and stopped, the maintenance workload will be very large:
( 1-1) To build image from Dockerfile or to pull image from docker hub
(1-2) To create multiple containers
(1-3) To manage these containers (start, stop, delete)

Service Orchestration: Manage containers in batches according to certain business rules.

(2) Docker Compose
Docker Compose is a tool for orchestrating multi-container distributed deployment. It provides a command set to manage the complete development cycle of containerized applications, including service construction, start and stop.
Use steps:
(2-1) Use Dockerfile to define the operating environment image
(2-2) Use docker-compose.yml to define the services that make up the application
(2-3) Run docker-compose up to start the application

2 Install Docker Compose

2.1 Installation method one

(1) Installation docker-compose
manner compiled binary packages installed in the linux system
#curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose- uname -s- uname -m- o /usr/local/bin/docker-compose
Set file executable permissions
#chmod +x /usr/local/bin/docker-compose
View version information
#docker-compose -version

(2) Uninstall the docker-compse
binary package, just delete the binary file.
#rm /usr/local/bin/docker-compose

2.2 Installation method two

#pip install docker-compose
#docker-compose version
docker-compose version 1.25.4, build unknown
docker-py version: 4.2.0
CPython version: 3.7.0
OpenSSL version: OpenSSL 1.0.2p 14 Aug 2018

3 Arrange nginx and flask

(1) Pull the nginx image remotely, just after pulling it, no need to do any processing
#docker pull nginx

(2) Create myflask:1.0 mirror

(3)Docker-compose configuration
#mkdir -p /root/mydockercompose #cd
/root/mydockercompose/
(3-1) Write docker-
compose.yml #vi docker-compose.yml [This file name is immutable]

在这里插入代码片

(3-2) Write the reverse proxy of nginx
#mkdir -p /root/nginx/conf.d
In this directory, write the reverse proxy file myflasknginx.conf

server {
    
    
    listen      80;

    location / {
    
    
        proxy_pass http://myname:5000/;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Note that because nginx and flask applications are not in the same container

(4) Start the service
#docker-compose up

(5) An external machine accessing
http://192.168.236.129:80
will be reverse proxy to
http://192.168.236.129:5000

Guess you like

Origin blog.csdn.net/qq_20466211/article/details/110369662