docker-compose部署微服务
1、安装docker-compose
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
面安装的是稳定版本1.23.2的 docker-compose,可以到github上找最新版 https://github.com/docker/compose/releases
执行如下命令,查看是否安装成功:
docker-compose version
2、创建docker-compose.yml文件
version: '3'
services:
demo-tm:
image: registry.cn-shanghai.aliyuncs.com/demo-store/demo_online:demo-tm-v1.0
container_name: demo-tm
ports:
- 7970:7970
- 8070:8070
networks:
- netName
demo-usercenter:
image: registry.cn-shanghai.aliyuncs.com/demo-store/demo_online:demo-usercenter-v1.0
container_name: demo-usercenter
ports:
- 9001:9001
networks:
- netName
demo-pay:
image: registry.cn-shanghai.aliyuncs.com/demo-store/demo_online:demo-pay-v1.0
container_name: demo-pay
ports:
- 9009:9009
volumes:
- /home/pinganBank:/home/pinganBank
networks:
- netName
demo-gateway:
image: registry.cn-shanghai.aliyuncs.com/demo-store/demo_online:demo-gateway-v1.0
container_name: demo-gateway
ports:
- 10001:10001
networks:
- netName
networks:
netName:
driver: bridge
3、进入docker-compose.yml所在文件夹,执行以下命令,启动服务
docker-compose up -d
4、其他相关docker-compose命令
停止所有服务
decker-compose stop
停止某服务
docker-compose stop demo-usercenter
删除所有服务镜像
docker-compose rm
其他更多命令可参考:https://www.cnblogs.com/moxiaoan/p/9299404.html