[docker] docker-compose service orchestration

1. The concept of service orchestration

  • 1. The application system of the microservice architecture generally contains several microservices, and each microservice usually deploys multiple instances. If each microservice needs to be started manually, the maintenance workload will be heavy
  • 2. Maintenance work such as: build image from dockerfile or pull image from dockerhub, create multiple containers, manage container start, stop, delete, etc.
  • 3. Service orchestration is to manage containers in batches according to certain business rules

Two, docker compose

2.1 Definition
  • 1.docker compose is a tool for orchestrating distributed deployment of multiple containers, providing a command set to manage the complete development cycle of containerized applications, including service construction, start and stop
2.2 Steps to use
  • 1. Use Dockerfile to define the running environment image
  • 2. Use docker-compose.yml to define the services that make up the application
  • 3. Run docker-compose up to start the application
2.3 docker-compose installation
  • 1. At present, Linux, Mac OS and Windows are fully supported. Before installing compose, install docker first
  • 2. Linux installation
curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# 设置文件可执行权限
sudo chmod +x /usr/local/bin/docker-compose
# 查看版本信息
docker-compose -version

insert image description here
insert image description here

2.4 docker-compose uninstall
  • 1. Binary package installation, just delete the binary file
rm /usr/local/bin/docker-compose

3. Arrangement example

  • 1. Create a docker-compose directory
mkdir ~/docker-compose
cd ~/dokcer-compose
  • 2. Write docker-compose file
version: '3'
services:
	nginx:
		image: nginx
		ports:
			- 80:80
		links:
			- app
		volumes:
			- ./nginx/conf.d:/etc/nginx/conf.d
	app:
		image: app
		expose:
			- "8080"
  • 3. Create the ./nginx/conf.d directory
mkdir -p ./nginx/conf.d
  • 4. Edit the nginx.conf file
server {
	listen 80;
	access_log off;
	location / {
		proxy_pass http://app:8080;
	}
}
  • 5. start
    insert image description here
    insert image description here

  • 6. Access
    insert image description here

Guess you like

Origin blog.csdn.net/qq_32088869/article/details/132117036