Google chrome and localhost in swarm mode

Hi,

I have the following tiny issue : google chrome (chromium actually) can’t connect to the http services in my containers in my local swarm using “localhost” domain.
It’s really specific : only with localhost (other domain aliases or 127.0.0.1 work), only with chrome (firefox and wget are ok) and only from containers in a service stack (it works when i run a container directly).
It’s really not critical but i’d like to understand, and networking is not what i know most.

The stack has nothing special : there are 3 different services linked together by the implicit automatic network. It’s merely what we can see in the getting started guides, except i used “mode: global” for the “deploy” parameters.

Everything run on the same computer, on Ubuntu 16
Docker Server Version: 17.03.1-ce

$ docker network ls
NETWORK ID          NAME                     DRIVER              SCOPE
32562cc1e37a        bridge                   bridge              local
63057fc50251        docker_gwbridge          bridge              local
a3fcb51d7269        host                     host                local
ha4btuki0jtc        ingress                  overlay             swarm
r9ho0gy0v6ub        my-local-stack_default   overlay             swarm
673761bc23d3        none                     null                local
$ netstat -n
Table de routage IP du noyau
Destination     Passerelle      Genmask         Indic   MSS Fenêtre irtt Iface
default         192.168.0.254   0.0.0.0         UG        0 0          0 wlp3s0
link-local      *               255.255.0.0     U         0 0          0 docker_gwbridge
172.17.0.0      *               255.255.0.0     U         0 0          0 docker0
172.18.0.0      *               255.255.0.0     U         0 0          0 docker_gwbridge
192.168.0.0     *               255.255.255.0   U         0 0          0 wlp3s0
4 Likes

Hi, I’m facing exactly the same problem (Docker version 17.09.0-ce, build afdb6d4), it’s a very weird behaviour.
Any tips?

Also facing the exact same problem, would be great if anyone with greater network experience can explain this.

I also have the same problem. It can be checked as

docker service create \
--name test \
--replicas 1 \
-p 8080:80 \
nginx

After run this service try to open localhost:8080 in Google Ghrome.

My version of docker

$ docker version
Client:
 Version:      17.11.0-ce
 API version:  1.34
 Go version:   go1.8.3
 Git commit:   1caf76c
 Built:        Mon Nov 20 18:37:39 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.11.0-ce
 API version:  1.34 (minimum version 1.12)
 Go version:   go1.8.3
 Git commit:   1caf76c
 Built:        Mon Nov 20 18:36:09 2017
 OS/Arch:      linux/amd64
 Experimental: false

I’m facing the exact same problem.

$ docker version
Client:
 Version:      17.03.1-ce
 API version:  1.27
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:14:09 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.03.1-ce
 API version:  1.27 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   c6d412e
 Built:        Mon Mar 27 17:14:09 2017
 OS/Arch:      linux/amd64

I’m using Chrome.

$ google-chrome --version
Google Chrome 59.0.3071.86 

My OS is Ubuntu.

$ uname -a
Linux xxx 4.4.0-104-generic #127-Ubuntu SMP Mon Dec 11 12:16:42 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

Any solution or workaround?

The problem that you can’t connect to the http services in my containers in my local swarm using “localhost” domain seems pretty hard to solve. You should check out this website Chrome ERR_CONNECTION_RESET Error for solution to your problem. Hope this helps.

Having the same issue also. I can connect using 127.0.0.1 from Chrome but not using localhost. There are no issues using localhost with curl and Firefox.

Same issue here. This is very inconvenient as my other components send responses with ACCESS-CONTROL-ALLOW-ORIGIN tailored to xx.localhost, not to an ip address.

I need more recent versions (I would like to get the npm 5.6.0 version) in order to be able to build another project inside the laptop repair image.

I’m still facing the same issue. Looks like there hasn’t been any changes in the two years since this was first raised?

→ docker version
Client:
 Version:           18.09.3
 API version:       1.39
 Go version:        go1.10.8
 Git commit:        774a1f4
 Built:             Thu Feb 28 06:47:20 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.3
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.8
  Git commit:       774a1f4
  Built:            Thu Feb 28 05:59:55 2019
  OS/Arch:          linux/amd64
  Experimental:     false

I’m having the exact same issue, apparently chrome is using the ipv6 localhost.

To reproduce in curl try
curl -v ip6-localhost:$SERVICE_PORT
or if ip6-localhost is not set in your hosts file
curl -v ::1:$SERVICE_PORT

If anyone knows how to get chrome to not bypass the hosts file please let me know. For now the workaround has to be use 127.0.0.1 which is very annoying.

It’s 2022, and the problem persists. Google Chrome can’t open localhost urls. Firefox works, curl does as well.

It only happens when the port is exposed in the ingress mode and not the host mode described here: