Then I put the file into an image to the container registry and I docker pull it on every node that I create. Finally, I made a docker service with the image with the command
docker service create --name kk-vod --replicas 3 -p 80:80 gcr.io/vodskripsisalsa/kk-vod
After I checked with docker ps, all the containers were active. But when I try to curl the ip address it only works once out of 3 attempts, why does this happen?
I formatted your post. If you click on the edit pencil on your first post, you can see how I changed it. Please format your following posts accordingly.
How does the output of docker service ps kk-vod look like?
You might want to add --with-registry-auth to your command, so that the service will be able to pull the image by itself when deploying the task container.
It could be a problem related to overlay networks, that prevent the ingress routing mesh to forward traffic in the overlay network to other nodes.
Make sure these ports are not blocked by any firewall:
If you don’t know the ip’s of your swarm nodes, execute this snippet on the master node:
node_ids=$(docker node ls -q)
for node in ${node_ids}; do
docker node inspect ${node} --format '{{.Status.Addr}}'
done
Then replace the value of check_ips in the next snippet with the ip’s you get from the previous command and execute the complete block on each of the swarm nodes:
check_ips="192.168.200.21 192.168.200.22 192.168.200.23"
for _ip in ${check_ips}; do
echo "## ip: ${_ip}"
nc -zv ${_ip} -t 2377 7946
nc -zv ${_ip} -u 7946 4789
done
## ip: 10.184.0.2
Connection to 10.184.0.2 2377 port [tcp/*] succeeded!
Connection to 10.184.0.2 7946 port [tcp/*] succeeded!
Connection to 10.184.0.2 7946 port [udp/*] succeeded!
Connection to 10.184.0.2 4789 port [udp/*] succeeded!
## ip: 10.184.0.5
nc: connect to 10.184.0.5 port 2377 (tcp) failed: Connection refused
Connection to 10.184.0.5 7946 port [tcp/*] succeeded!
Connection to 10.184.0.5 7946 port [udp/*] succeeded!
Connection to 10.184.0.5 4789 port [udp/*] succeeded!
## ip: 10.184.0.4
nc: connect to 10.184.0.4 port 2377 (tcp) failed: Connection refused
Connection to 10.184.0.4 7946 port [tcp/*] succeeded!
Connection to 10.184.0.4 7946 port [udp/*] succeeded!
Connection to 10.184.0.4 4789 port [udp/*] succeeded!
its the result, what next i do? when port 2377 failed
so like this I scaled the service as much as 3, but when testing curl with ip it was successful only once out of 3 attempts. note : all nodes are active, overlay network is connected, containers are all active. why?