1

Connection to a docker swarm service published port hangs after connecting. I have deployed a docker service using the command below.

docker service create --name my-nginx --replicas 1 --publish published=5033,target=80 nginx;

The connection to the port 5033 hangs waiting for response, see below. The command below

wget -v http://localhost:5033/;

Yields

--2022-09-21 17:04:41--  http://localhost:5033/
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:5033... connected.
HTTP request sent, awaiting response... ^C

OS is

$ cat /etc/redhat-release

CentOS Linux release 7.9.2009 (Core)

kernel is

$ uname -rv

3.10.0-1160.36.2.el7.x86_64 #1 SMP Wed Jul 21 11:57:15 UTC 2021

Docker version is

$ docker version
Client: Docker Engine - Community
 Version:           20.10.18
 API version:       1.41
 Go version:        go1.18.6
 Git commit:        b40c2f6
 Built:             Thu Sep  8 23:14:08 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.18
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.18.6
  Git commit:       e42327a
  Built:            Thu Sep  8 23:12:21 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.8
  GitCommit:        9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
Allan K
  • 151
  • 6

2 Answers2

2

With ipv6 enabled localhost resolved to ipv6 ::1 because ipv6 has priority over ipv4.

You may check it with ping localhost.

Disable ipv6 if you not use it

gapsf
  • 846
  • 1
  • 6
  • 12
1

I was able to have successful connectivity when I replaced "localhost" with "127.0.0.1".

It seems 127.0.0.1 should be used in place of localhost.

Publishing this so it may help someone else.

Allan K
  • 151
  • 6