Hi
I use the following .yml to deploy a Postgres service.
version: “3”
services:
postgres:
image: postgres:9.5
volumes:
- db-data:/var/lib/postgresql/data
networks:
- postgres
deploy:
placement:
constraints: [node.role == worker]
networks:
postgres:
volumes:
db-data:
driver: "vmdk"
driver_opts:
size: “500MB”
What I found is the task is scheduled on the worker-node as expected, but only last for several seconds, and then the container shutdown and Swarm restart another container on the same node. Any ideas?
I also try to deploy with local volumes, and it works fine. I don’t know why it works with local volume.
Output from Master node:
root@esx1-swarm01:~# docker service ls
ID NAME MODE REPLICAS IMAGE
sp4ec5qyixqh postgres_postgres replicated 0/1 postgres:9.5
root@esx1-swarm01:~# docker service ps postgres_postgres
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
frhvciz1hokz postgres_postgres.1 postgres:9.5 esx1-swarm02 Running Starting less than a second ago
ak2ak21i1zdi _ postgres_postgres.1 postgres:9.5 esx1-swarm02 Shutdown Failed 5 seconds ago "task: non-zero exit (1)"
q6240vlajwn3 _ postgres_postgres.1 postgres:9.5 esx1-swarm02 Shutdown Failed 14 seconds ago "task: non-zero exit (1)"
j3y42ji0la5q _ postgres_postgres.1 postgres:9.5 esx1-swarm02 Shutdown Failed 23 seconds ago "task: non-zero exit (1)"
jxwjfw71kmnk _ postgres_postgres.1 postgres:9.5 esx1-swarm02 Shutdown Failed 34 seconds ago “task: non-zero exit (1)”
Output put from the worker node which the task is scheduled:
root@esx1-swarm01:~# docker service ls
ID NAME MODE REPLICAS IMAGE
sp4ec5qyixqh postgres_postgres replicated 0/1 postgres:9.5
root@esx1-swarm01:~# docker service ps postgres_postgres
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
frhvciz1hokz postgres_postgres.1 postgres:9.5 esx1-swarm02 Running Starting less than a second ago
ak2ak21i1zdi _ postgres_postgres.1 postgres:9.5 esx1-swarm02 Shutdown Failed 5 seconds ago "task: non-zero exit (1)"
q6240vlajwn3 _ postgres_postgres.1 postgres:9.5 esx1-swarm02 Shutdown Failed 14 seconds ago "task: non-zero exit (1)"
j3y42ji0la5q _ postgres_postgres.1 postgres:9.5 esx1-swarm02 Shutdown Failed 23 seconds ago "task: non-zero exit (1)"
jxwjfw71kmnk _ postgres_postgres.1 postgres:9.5 esx1-swarm02 Shutdown Failed 34 seconds ago “task: non-zero exit (1)”
I saw a lot of error like “task:non-zero exit (1)”, but how can I know the detailed reason why the task is failed on the worker node?
Thanks!