I hope this is the correct forum for my question. I’m trying to deploy a starman psgi service to my development 1 node swarm but am unable to make a successful connection to the service when run as a stack. The service is being proxied by a local apache server. I’ve successfully deployed similar stacks but cannot get this to work properly other than using “docker run”. I feel like I’m missing something fundamental here, but I’m at a loss as to what it might be. Below is my my compose file and some command output that should clarify my issue:
version: "3.7"
services:
starman-devel:
image: myregistry/starman_dev:latest
hostname: starman-devel
ports:
- target: 3131
published: 3129
protocol: tcp
mode: host
If I change the mode to “ingress” or simply define ports in the compose file to “3129:3131” with no difference.
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2576402a1314 myregistry/starman_dev:latest "/bin/sh -c '/etc/in…" 3 minutes ago Up 3 minutes 0.0.0.0:3129->3131/tcp Starman_STK_starman-dev.1.b2vnp4i0ygioflcxujmlamouw
$ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS
x4lr5ttsc7cb Starman_STK_starman-dev replicated 1/1 myregistry/starman_dev:latest
$ telnet localhost 3129
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.
$ netstat -an |grep 3129
tcp6 0 0 :::3129 :::* LISTEN
When I attempt to connect, apache gives me a 502 error (“The proxy server received an invalid response from an upstream server.”) Attempting to telnet to the port from the swarm node yields an immediate closed connection. The application does not record any connections. I’ve verified that the application running in the container is actually listening on it’s defined port and it is working properly.
If I run the container "manually"with a docker run command, it works perfectly:
$ docker run --rm --name StarmanTest2 -p 3129:3131 --hostname=starman-dev -d myregistry/starman_dev:latest
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9166217a2671 myregistry/starman_dev:latest "/bin/sh -c '/etc/in…" 27 minutes ago Up 27 minutes 0.0.0.0:3129->3131/tcp StarmanTest2
$ telnet localhost 3129
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
In addition, I’ve opened up port 3129 on the host firewall to all traffic. port forwarding is enabled for both ipv4 and ipv6.
The swarm node is running docker-ce 19.03 on RHEL/CentOS 7.7