I am working on a docker application in which I have created a trial repository for testing docker swarm. I have created a docker-compose.yml file and pointing it to my public repository. Without the swam mechanism, it works fine, but I am not getting any response when I have it inside swarm.
docker-compose.yml :
version: "3"
services:
web:
image: repo-link
deploy:
replicas: 5
resources:
limits:
cpus: "0.1"
memory: 50M
restart_policy:
condition: on-failure
ports:
- "4000:80"
networks:
- webnet
networks:
webnet:
I can see the VMs running properly with a leader
docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
myvm1 * virtualbox Running tcp://192.168.99.100:2376 v18.09.0
myvm2 - virtualbox Running tcp://192.168.99.101:2376 v18.09.0
PS command
docker stack ps project
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
mdb4b82nnkvu project_web.1 username/project:part1 myvm2 Running Running 13 minutes ago
shf6qmhzbtaq project_web.2 username/project:part1 myvm2 Running Running 13 minutes ago
ou5hy1uz6sh9 project_web.3 username/project:part1 myvm1 Running Running 13 minutes ago
kv4rvq1huxv4 project_web.4 username/project:part1 myvm2 Running Running 13 minutes ago
xtbc20orfd58 project_web.5 username/project:part1 myvm1 Running Running 13 minutes ago
Commands used :
docker-machine create --driver virtualbox myvm1
docker-machine create --driver virtualbox myvm2
docker-machine ssh myvm1 "docker swarm init --advertise-addr <myvm1 ip>"
docker-machine ssh myvm2 "docker swarm join --token TOKEN 192.168.99.100:2377"
eval $(docker-machine env myvm1)
docker stack deploy -c docker-compose.yml project
sudo iptables -I INPUT -p tcp -m tcp --dport 7946 -j ACCEPT
sudo iptables -I INPUT -p udp -m udp --dport 4789 -j ACCEPT
I still cant get any response on localhost or Curl, it just says unable to connect. What am I doing wrong?