我尝试使用docker stack deploy
命令部署一个堆栈(包含一个服务),并在 swarm 上从我的应用程序运行 2 个实例!这是我的 docker-compose 文件:
version: "3"
services:
server:
image: makbn/thumbnailer-server:v1
deploy:
replicas: 2
update_config:
parallelism: 2
resources:
limits:
cpus: "0.1"
memory: 1024M
restart_policy:
condition: on-failure
ports:
- 8080:8080
networks:
- server_network
networks:
server_network:
运行sudo docker stack deploy -c ./docker-compose.yml ts
命令后,我的堆栈成功部署到 swarm,但这是我的docker stack ps ts
输出:
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
8zmjp6wt47ki ts_server.1 makbn/thumbnailer-server:v1 fanap9-lp Ready Rejected 2 seconds ago "mkdir /var/lib/docker: permis…"
88vizpnabbi8 \_ ts_server.1 makbn/thumbnailer-server:v1 fanap9-lp Shutdown Rejected 7 seconds ago "mkdir /var/lib/docker: permis…"
609hl7hy7tnu \_ ts_server.1 makbn/thumbnailer-server:v1 fanap9-lp Shutdown Rejected 12 seconds ago "mkdir /var/lib/docker: permis…"
gif8fvbgdhpy \_ ts_server.1 makbn/thumbnailer-server:v1 fanap9-lp Shutdown Rejected 17 seconds ago "mkdir /var/lib/docker: permis…"
x60x9c6albe5 \_ ts_server.1 makbn/thumbnailer-server:v1 fanap9-lp Shutdown Rejected 22 seconds ago "mkdir /var/lib/docker: permis…"
ugvbw1gpdp8e ts_server.2 makbn/thumbnailer-server:v1 fanap9-lp Ready Rejected 2 seconds ago "mkdir /var/lib/docker: permis…"
p34x1kp55ch8 \_ ts_server.2 makbn/thumbnailer-server:v1 fanap9-lp Shutdown Rejected 7 seconds ago "mkdir /var/lib/docker: permis…"
3exxflukrl4y \_ ts_server.2 makbn/thumbnailer-server:v1 fanap9-lp Shutdown Rejected 12 seconds ago "mkdir /var/lib/docker: permis…"
ud83xfj5nefj \_ ts_server.2 makbn/thumbnailer-server:v1 fanap9-lp Shutdown Rejected 17 seconds ago "mkdir /var/lib/docker: permis…"
ws35na8up793 \_ ts_server.2 makbn/thumbnailer-server:v1 fanap9-lp Shutdown Rejected 22 seconds ago "mkdir /var/lib/docker: permis…"
完整的错误消息是mkdir /var/lib/docker: permission denied
另一个问题是,当我尝试使用已docker service create
部署并成功运行的命令服务创建堆栈时,但我无法从本地主机访问该服务!我有两个问题:
- 从撰写文件部署堆栈有什么问题,为什么我得到mkdir /var/lib/docker: permission denied错误?
- 如何将我的服务网络 k 配置为可从主机访问?