0

I am trying to deploy the application on multiple instances. On master node. after deployed application running the only master node. cannot deploy service different node in the docker swarm cluster. here my docker-compose file

version: "3"

services:

  mydb:
    image: localhost:5000/mydb-1
    environment:
      TZ: "Asia/Colombo"
    ports:
      - 9042:9042
    volumes:
      - /root/data/cdb:/var/lib/cassandra
      - /root/logs/cdb:/var/log/cassandra

command docker service scale mydb-1_mydb=5

CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                                                 NAMES
7fxxxxxxxx7        localhost:5000/mydb-1:latest   "docker-entrypoint.sh"   16 seconds ago      Up 5 seconds        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp           mydb-1_mydb.2.q77i258vn2xynlgein9s7tdpb
34fcxxxx14bd        localhost:5000/mydb-1:latest   "docker-entrypoint.sh"   16 seconds ago      Up 4 seconds        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp           mydb-1_mydb.1.s2mzitj8yzb0zo7spd3dmpo1j
9axxxx1efb        localhost:5000/mydb-1:latest   "docker-entrypoint.sh"   16 seconds ago      Up 8 seconds        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp           mydb-1_mydb.3.zgyev3p4qdg7hf7h67oeedutr
f14xxxee59        localhost:5000/mydb-1:latest   "docker-entrypoint.sh"   16 seconds ago      Up 2 seconds        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp           mydb-1_mydb.4.r0themodonzzr1izdbnppd5bi
e3xxx16d        localhost:5000/mydb-1:latest   "docker-entrypoint.sh"   16 seconds ago      Up 6  seconds        7000-7001/tcp, 7199/tcp, 9042/tcp, 9160/tcp           mydb-1_mydb.5.bdebi4

all running only master-node. Does anyone know the issue?

3
  • What docker node ls returns? Commented Jan 28, 2020 at 11:36
  • yes. showing all node active state Commented Jan 28, 2020 at 11:38
  • ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION pcmabdsjxxxxxxxxxxxxxxxxd * beta-master Ready Active Leader 19.03.5 iptx66h4xxxxxxxxxxxxxz820 beta-node-1 Ready Active 19.03.5 kqylfxxxxxxxxxxxxxxxx3b11k beta-node-2 Ready Active 19.03.5 @samthegolden Commented Jan 28, 2020 at 11:41

2 Answers 2

1

Your image appears to be locally built with a name that cannot be resolved in other nodes (localhost:5000/mydb-1). In swarm, images should be pushed to a registry, and that registry needs to be accessible by all nodes. You can run your own registry service on your own node, there's a docker image, or you can push to docker hub. If the registry is private, you also need to perform a docker login on the node running the stack deploy and include registry credentials in that deploy, e.g.

docker stack deploy -c compose.yml --with-registry-auth stack-name
Sign up to request clarification or add additional context in comments.

2 Comments

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES dbxxxx42f9 registry:2 "/entrypoint.sh /etc…" 20 hours ago Up 2 hours 5000/tcp registry.1.to4l4xj7kso44qr5dz8fj1fr5 actually this image here my local private registry root@beta-node-2:~# curl localhost:5000/v2/_catalog {"repositories":["mydb-1"]} my node
logging in and pulling the images from hub did that trick to me
0

Thanks. I find the issue and fixed.

volumes:
      - /root/data/cdb:/var/lib/cassandra
      - /root/logs/cdb:/var/log/cassandra

If you bind mount a host path into your service’s containers, the path must exist on every swarm node.

docker service scale zkr_zkr=2

after scale-up service running my node

root@beta-node-1:~# docker ps
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS                                    NAMES
f9bxxx15861        localhost:5000/zookeeper:latest   "/docker-entrypoint.…"   40 minutes ago      Up 40 minutes       2181/tcp, 2888/tcp, 3888/tcp, 8080/tcp   zkr_zkr.3.qpr8qp5y
01dxxxx64bc        localhost:5000/zookeeper:latest   "/docker-entrypoint.…"   40 minutes ago      Up 40 minutes       2181/tcp, 2888/tcp, 3888/tcp, 8080/tcp   zkr_zkr.1.g2uee5j

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.