六十六、Docker Swarm-练习部署投票app
2022-01-16 本文已影响0人
InsaneLoafer
swarm 部署投票 app
GitHub源码 https://github.com/dockersamples/example-voting-app
Gitee源码https://gitee.com/landylee007/voting-app.git
需要修改docker-stack.yml
文件db的环境变量
db:
image: postgres:9.4
environment:
POSTGRES_USER: "postgres"
POSTGRES_PASSWORD: "postgres"
POSTGRES_HOST_AUTH_METHOD: "trust"
volumes:
- db-data:/var/lib/postgresql/data
实战
[vagrant@swarm-manager example-voting-app-master]$ docker stack deploy --compose-file docker-stack.yml vote
Updating service vote_db (id: bdf5okdg5515i4z5pasogt4gs)
Updating service vote_vote (id: l1f636p7ocxcy2h86eu5johge)
Updating service vote_result (id: zmjos94aow9gbnf97etnxuypx)
Updating service vote_worker (id: sxsqnrlhlka4mh1xveziw0jpg)
Updating service vote_visualizer (id: pzy5z4bte3uxkr4ze6zgjaarx)
Updating service vote_redis (id: i2xoyq3b8vpndamxyv6pcjb1r)
[vagrant@swarm-manager example-voting-app-master]$
[vagrant@swarm-manager example-voting-app-master]$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
bdf5okdg5515 vote_db replicated 1/1 postgres:9.4
i2xoyq3b8vpn vote_redis replicated 1/1 redis:alpine
zmjos94aow9g vote_result replicated 1/1 dockersamples/examplevotingapp_result:before *:5001->80/tcp
pzy5z4bte3ux vote_visualizer replicated 1/1 dockersamples/visualizer:stable *:8080->8080/tcp
l1f636p7ocxc vote_vote replicated 2/2 dockersamples/examplevotingapp_vote:before *:5000->80/tcp
sxsqnrlhlka4 vote_worker replicated 0/1 dockersamples/examplevotingapp_worker:latest