I am running a docker:20.10.7-dind
container.
Into this one I am running a multi containers app.
One container is a back
container. Another one is a keycloak
container.
I connect on the back
container and have :
back$ cat /etc/resolv.conf
nameserver 127.0.0.11
options ndots:0
back$ cat /etc/nsswitch.conf
hosts: files dns
back$ nslookup keycloak.localhost
Server: 127.0.0.11
Address: 127.0.0.11#53
Non-authoritative answer:
Name: keycloak.localhost
Address: 172.20.0.10
back$ host keycloak.localhost
keycloak.localhost has address 172.20.0.10
back$ nc keycloak.localhost 443 -vvv
keycloak.localhost (172.20.0.10:443) open
However, when it comes to curl :
back$ curl https://keycloak.localhost -v
* Trying 127.0.0.1:443...
* connect to 127.0.0.1 port 443 failed: Connection refused
* Trying [::1]:443...
* Immediate connect fail for ::1: Address not available
* Failed to connect to keycloak.localhost port 443 after 0 ms: Couldn't connect to server
* Closing connection 0
curl: (7) Failed to connect to keycloak.localhost port 443 after 0 ms: Couldn't connect to server
I notice that curl badly resolve the keycloak.localhost
but I cannot figure out why ?
Note that if I help curl to resolve, it works like a charm :
back$ curl https://keycloak.localhost -v --resolve keycloak.localhost:443:172.20.0.10
* Added keycloak.localhost:443:172.20.0.10 to DNS cache
* Hostname keycloak.localhost was found in DNS cache
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* Trying 172.20.0.10:443...
* Connected to keycloak.localhost (172.20.0.10) port 443 (#0)
> GET / HTTP/2
> Host: keycloak.localhost
> user-agent: curl/8.0.1
> accept: */*
>
< HTTP/2 200
...
I would appreciate any clue to help me understand this.
Cheers