Search code examples
dockerdocker-swarm

replicas of a service in docker swarm remain 0/1 forever


yes, I already tried this Question and ir doesnt a duplicate question

Im learning use the docker swarm and Im using the docker-play
I have a manager(node1) and 2 workers(node2 and node3)

$ docker node ls
ID                            HOSTNAME            STATUS              AVAILABILITY        MANAGER STATUS
j4maivz26wactwn9ghgosg219     node2               Ready               Active
p6cpvetwrsqu6oiqzfq2bxxsv     node3               Ready               Active
r7y5zktfore76l9z3n0keu7ae *   node1               Ready               Active              Leader

so i created a service

 docker service create --network ingress --name mysql -e MYSQL_ROOT_PASSWORD=demodocker -e MYSQL_DATABASE=wordpressdatabase -e M
YSQL_USER=root -e MYSQL_PASSWORD=demodocker mysql

and the replicas remain 0/1 forever

$ docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE               PORTS
jub3wh8yz2cd        mysql              replicated          0/1                 mysql:latest

so i try:

 docker service create --network ingress --name mysql2 -e MYSQL_ROOT_PASSWORD=demodocker -e MYSQL_DATABASE=wordpressdatabase -e M
YSQL_USER=root -e MYSQL_PASSWORD=demodocker mysql:latest top

and i try:

 docker service create --network ingress --replicas 1 --name mysql2 -e MYSQL_ROOT_PASSWORD=demodocker -e MYSQL_DATABASE=wordpressdatabase -e M
YSQL_USER=root -e MYSQL_PASSWORD=demodocker mysql:latest top

I try the most simple code line:

docker service create --network ingress --name mysql -e MYSQL_ROOT_PASSWORD=demodoceker mysql

but anything work, i looked this question too but i dont find none parameter wrong

more information:

$ docker service ps mysql
ID                  NAME                IMAGE               NODE                DESIRED STATE       CURRENT STATE        ERROR
           PORTS
j523hr6mnfqk        mysql            mysql:latest                            Running             New 13 minutes ago

.

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
wordpress           latest              ca96afcfa242        2 weeks ago         406MB
mysql               latest              e799c7f9ae9c        3 weeks ago         407MB

Thank you ;)


Solution

  • Don't attach services directly to the ingress network. That seems to be causing the issue as I don't experience the same when removing --network ingress. I can reproduce the above (with --network ingress set) and I don't see any logs (service or daemon) that might give a clue about why it's failing, so that's not great I guess. Maybe raise an issue with Docker for better logging / error here?

    The ingress network is used when publishing ports for the service so let Docker manage attachments to that directly.

    Edit: Btw, this will still fail after you take that out, for mysql reasons (failure to create table I believe? But the service itself is attempting to come up).