swarmkit icon indicating copy to clipboard operation
swarmkit copied to clipboard

service creation failing

Open ukreddy-erwin opened this issue 5 years ago • 2 comments

cassandra db, able to create as a container but as a swarm service, it is failing.

I am creating service of swarm using this:

docker service create --name some-cassandra -d -p target=7000 -p target=9042 cassandra:latest

But, my service is getting failed for every few seconds

ubuntu@ip-172-31-25-90:~$ docker service ls

ID NAME MODE REPLICAS IMAGE PORTS 7t0nurasar5s some-cassandra replicated 0/1 cassandra:latest *:30002->7000/tcp, *:30003->9042/tcp

ubuntu@ip-172-31-25-90:~$ docker service ps 7t

ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS xo10xhi8khn9 some-cassandra.1 cassandra:latest ip-172-31-25-90 Ready Ready 4 seconds ago 68y0k1f2f90d _ some-cassandra.1 cassandra:latest ip-172-31-25-90 Shutdown Failed 4 seconds ago “task: non-zero exit (1)” x2o6bmix0x8e _ some-cassandra.1 cassandra:latest ip-172-31-25-90 Shutdown Failed 14 seconds ago “task: non-zero exit (1)” lr6v50lumdlo _ some-cassandra.1 cassandra:latest ip-172-31-25-90 Shutdown Failed 24 seconds ago “task: non-zero exit (1)” n0o38mkfack9 _ some-cassandra.1 cassandra:latest ip-172-31-25-90 Shutdown Failed 34 seconds ago “task: non-zero exit (1)”

When I checked the logs of the latest one.

ubuntu@ip-172-31-25-90:~$ docker service logs ut pslog.txt

ukreddy-erwin avatar May 29 '20 10:05 ukreddy-erwin

Someone suggested to use a separate bridge network and use that instead of the default one. It is working. But, why it is not working with the default network?

ukreddy-erwin avatar May 29 '20 10:05 ukreddy-erwin

Cassandra is failing because it couldn't resolve its own hostname. When using docker run or docker-compose, docker adds the container hostname to /etc/hosts. Same happens with Docker Swarm, but you need to add your service to a network (eg. docker service create --name some-cassandra --network=some-network -d -p target=7000 -p target=9042 cassandra:latest).

akerouanton avatar Jul 28 '20 11:07 akerouanton