Closed mechdeveloper closed 5 years ago
Update: this works on a public network but fails on a protected network. I am still trying to understand what is wrong with the machines on protected networks which prevents docker swarm mode services to work.
I tried the same scenario in my personal windows machine and it worked fine.
Update I found this-
Docker Swarm's routing mesh feature is not yet supported on Windows, but users seeking to publish ports for their service endpoints can do so today using publish-port mode.
refer this link
https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/swarm-mode#publish-ports-for-service-endpoints
The problem was proxy settings on the boot2docker vm i was running.
Docker toolbox for windows Services are refusing connection when using swarm mode on Docker toolbox for Windows
Note: (docker toolbox) Docker is running in a linux VM inside my local machine with an ip address of 192.168.99.101
Steps to Reproduce the issue -
Step 1: Initialize the swarm mode $ docker swarm init --advertise-addr 192.168.99.101 Swarm initialized: current node (yfgi1sjocv9jq74e97g6ya9fm) is now a manager.
Step 2: pull an nginx image $ docker pull nginx Using default tag: latest latest: Pulling from library/nginx a5a6f2f73cd8: Pull complete 1ba02017c4b2: Pull complete 33b176c904de: Pull complete Digest: sha256:5d32f60db294b5deb55d078cd4feb410ad88e6fe77500c87d3970eca97f54dba Status: Downloaded newer image for nginx:latest
Step 3: create nginx service and expose it to port 7070 $ docker service create --name svcnginx -p 7070:80 nginx 1rmtfr7hs0oashfmg6ty57nox overall progress: 1 out of 1 tasks 1/1: running verify: Service converged
Step 4: Check the service we just created $ docker service ls ID NAME MODE REPLICAS IMAGE PORTS 1rmtfr7hs0oa svcnginx replicated 1/1 nginx:latest *:7070->80/tcp
Step 5: Check the containers $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1d681e3d0ea7 nginx:latest "nginx -g 'daemon of" 16 seconds ago Up 15 seconds 80/tcp svcnginx.1.58wzzqwbrcd3vmt9ymyxy2mmn
Step 6: Try to access the running nginx service $ curl $(docker-machine ip default):7070 curl: (7) Failed to connect to 192.168.99.101 port 7070: Connection refused
Expected O/P: $ curl 192.168.99.101:7070 <!DOCTYPE html>
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
I am new to docker not really sure what i am doing wrong. Practiced these same steps here "https://www.katacoda.com/courses/docker/playground" and everything work fine.
Running standalone nginx contianer also works fine without creating service $ docker run -d -p 7000:80 nginx
$ curl $(docker-machine ip default):7000 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 612 100 612 0 0 40800 0 --:--:-- --:--:-- --:--:-- 40800<!DOCTYPE html>
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.