DockerCompose是Docker官方的容器编排工具
安装
1 2
| curl -L https://github.com/docker/compose/releases/download/1.24.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose chmod +x /usr/local/bin/docker-compose
|
配置文件
示例配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| version: "3"
services: gateway: image: registry.internal.sixi.com/sixi/api-gateway:latest ports: - "8080:8080" deploy: placement: constraints: [node.hostname == 206] version: '3' resources: limits: cpus: '0.50' memory: 512M reservations: cpus: '0.25' memory: 128M environment: SPRING_CLOUD_CONFIG_URI: http://config:8083 SPRING_CLOUD_CONFIG_PROFILE: test aliauth: image: registry.internal.sixi.com/sixi/aliauth-service:latest environment: SPRING_CLOUD_CONFIG_URI: http://config:8083 SPRING_CLOUD_CONFIG_PROFILE: test
networks: default: name: open
|
命令
- 单机部署
docker-compose up -d
- 集群部署
docker stack deploy -c docker-compose.yml open