创建db-compose.yml
version: "3"
services:
mysql:
image: sample.com/mysql:5.7.16
environment:
- MYSQL_ROOT_PASSWORD=password
deploy:
restart_policy:
condition: on-failure
ports:
- "4444:3306"
networks:
- webnet
networks:
webnet:
执行命令docker stack deploy -c db-compose.yml dbservice
运行服务,执行后会返回启动了的服务名称列表
查看运行中的服务,执行docker stack ps dbservice
查看运行中的服务日志,执行docker service logs -f dbservice_mysql
移除服务,执行docker stack rm dbservice
停止并移除所有container docker rm -v $(docker stop $(docker ps -a -q))
网友评论