I tried to deploy a stack (contains one service) with docker stack deploy
command and run 2 instance from my application on swarm! here is my docker-compose file:
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:
After running sudo docker stack deploy -c ./docker-compose.yml ts
command, My stack successfully deployed to swarm, But here is my docker stack ps ts
output:
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…"
And the full error message is mkdir /var/lib/docker: permission denied
And the other problem is when i tried to create stack with docker service create
command services deployed and running successfully but i cant access to the service from my localhost! i have 2 questions:
- what is the problem with deploy stack from compose file and why i get mkdir /var/lib/docker: permission denied error?
- how to configure my service networke k to accessible from host?