Reputation: 870
If that's interesting: OS: WIN10 (cygwin), code written in Java
.
I followed this example.
I'd expect to reach the
service
in front of thecontainer
, which is running on port 80, usingmyvm1IP:80
(browser ir curl). Somehow this does not work. Or am I missunderstoonding the port mapping of the service?*:8080->80/tcp
I got a running docker swarm cluster consisting of 2 nodes. I am able to ping both of the running VMs
I already downgraded the version as there were issues with more recent version numbers. Information about the engine using docker inspect vmName
:
"Engine": {
"EngineVersion": "18.06.1-ce",
"Labels": {
"provider": "hyperv"
},
I executed the following docker-compose.yml
:
version: "3"
services:
web:
image: elps/articleservice:1.1.0.4
deploy:
replicas: 2
restart_policy:
condition: on-failure
ports:
- "8080:80"
environment:
- MYSQL_HOST=192.168.178.82
- MYSQL_DB=article
- MYSQL_USER=root
- MYSQL_PASSWORD=abcdefg
networks:
- webnet
networks:
webnet:
Both replicas started successfully and are able to connect to the local running database (assuming that, as I had a look at the logs and everything was looking fine). The container are up and running.
Output of docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
979ed7ea88b7 elps/articleservice:1.1.0.4 "java -jar articlese…" 27 minutes ago Up 27 minutes 8080/tcp getstartedlab_web.1.j1j41so8pz6atxqnq9fqqquk7
7684c3667025 elps/articleservice:1.1.0.4 "java -jar articlese…" 27 minutes ago Up 27 minutes 8080/tcp getstartedlab_web.2.r4kadvztiwgpckkuannnhcsea
Output of docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
gvyi9moxtpvq getstartedlab_web replicated 2/2 elps/articleservice:1.1.0.4 *:8080->80/tcp
Output of docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
myvm1 * hyperv Running tcp://192.168.178.88:2376 v18.06.1-ce
myvm2 - hyperv Running tcp://192.168.178.89:2376 v18.06.1-ce
When I try to execute curl myvmIP:80
I recieve
Failed to connect to 192.168.178.88 port 80: Connection refused
as response. I'd expect recieving a 404
error code as there is no mapping for /
. Am I wrong with this?
Upvotes: 3
Views: 811
Reputation: 870
Okay, so I simply tested switching all the ports I had, as I was kind of sure there was something wrong.
After switching the ports in service config (docker-compose.yml
) it works fine.
So the working docker-compose.yml
looks like this:
version: "3"
services:
web:
image: elps/articleservice:1.1.0.4
deploy:
replicas: 2
restart_policy:
condition: on-failure
ports:
- "80:8080"
environment:
- MYSQL_HOST=192.168.178.82
- MYSQL_DB=article
- MYSQL_USER=root
- MYSQL_PASSWORD=abcdefg
networks:
- webnet
networks:
webnet:
So incoming traffic gets redirected as follows:
Incoming traffic -> 80:
Service
->8080:Container
Upvotes: 2