1.部署swarm的stack部署wordpress。
2.参考官方文档
https://docs.docker.com/compose/compose-file/
1.docker stack部署帮助命令
[vagrant@swarm-manager wordpress0714]$ docker stack Usage: docker stack [OPTIONS] COMMAND Manage Docker stacks Options: --orchestrator string Orchestrator to use (swarm|kubernetes|all) Commands: deploy Deploy a new stack or update an existing stack ls List stacks ps List the tasks in the stack rm Remove one or more stacks services List the services in the stack Run 'docker stack COMMAND --help' for more information on a command.
2. docker-compose.yml文件
version: '3' services: web: image: hub.c.163.com/library/wordpress ports: - 8080:80 environment: WORDPRESS_DB_HOST: mysql WORDPRESS_DB_PASSWORD: root networks: - my-network depends_on: - mysql deploy: mode:replicated replicas: 3 restart_policy: condition: on-failure delay: 5s max_attempts: 3 update_config: parallelism: 1 delay: 10s mysql: image: hub.c.163.com/library/mysql:5.7 environment: MYSQL_ROOT_PASSWORD: root MYSQL_DATABASE: wordpress volumes: - mysql-data:/var/lib/mysql networks: - my-network deploy: mode: global placement: constraints: - node.role == manager volumes: mysql-data: networks: my-network: driver: overlay
备注:文件格式很重要,每个空格错了都不行。这个文件是成功了的。
3.部署
[vagrant@swarm-manager wordpress0714]$ docker stack deploy wordpress --compose-file=docker-compose.yml Creating network wordpress_my-network Creating service wordpress_web Creating service wordpress_mysql
4.查看stack
(1)查看stack服务
[vagrant@swarm-manager wordpress0714]$ docker stack ls NAME SERVICES ORCHESTRATOR wordpress 2 Swarm
(2)查看stack服务细节
[vagrant@swarm-manager wordpress0714]$ docker stack ps wordpress ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS mp0xedknox3w wordpress_mysql.bq44d6sisyp1qphp378h7cgun hub.c.163.com/library/mysql:5.7 swarm-manager Running Running 31 seconds ago 7id3u2ye8zr6 wordpress_web.1 hub.c.163.com/library/wordpress:latest swarm-worker1 Running Running 32 seconds ago egf1ldntaq1g wordpress_web.2 hub.c.163.com/library/wordpress:latest swarm-worker2 Running Running 32 seconds ago v67pb9fe0qqz wordpress_web.3 hub.c.163.com/library/wordpress:latest swarm-manager Running Running 31 seconds ago
(3)查看services
[vagrant@swarm-manager wordpress0714]$ docker stack services wordpress ID NAME MODE REPLICAS IMAGE PORTS 4rf8jqvbzu4z wordpress_web replicated 3/3 hub.c.163.com/library/wordpress:latest *:8080->80/tcp 6u08swb0hzr1 wordpress_mysql global 1/1 hub.c.163.com/library/mysql:5.7
(4)查看部署wordpress应用
http://192.168.205.20:8080/
5.停止服务
[vagrant@swarm-manager wordpress0714]$ docker stack rm wordpress
原文链接:https://blog.csdn.net/u010886217/article/details/95865046
© 版权声明
声明📢本站内容均来自互联网,归原创作者所有,如有侵权必删除。
本站文章皆由CC-4.0协议发布,如无来源则为原创,转载请注明出处。
THE END