In my docker compose project i have services as below:
- Traefik for https, and proxy
- App as a node container:
- Shop as a PHP container:
- other containers
To make it work, i my host machine added below to /etc/hosts
127.0.0.1 app.pro.localhost shop.pro.localhost
Then i can access them from host machine properly.
Now i want to make the containers communicate with each other via HTTPS request as well then i did something like
app:
extra_hosts:
- "shop.pro.localhost:${HOST_IP}"
shop:
extra_hosts:
- "app.pro.localhost:${HOST_IP}"
With about configuration. now inside shop
container i can see 192.168.1.3 app.pro.localhost
in /etc/hosts
that allow to run curl
perfectly.
However, it does not work in the opposite of App -> Shop
.
/etc/hosts
is perfect as expexted as 192.168.1.3 shop.pro.localhost
.
When run a command curl -v
the output is always like
root@f97064001ee5:/app# curl -v
* Trying 127.0.0.1:443...
* connect to 127.0.0.1 port 443 failed: Connection refused
--------
root@f97064001ee5:/app# getent hosts shop.pro.localhost
192.168.1.10 shop.pro.localhost
-----
root@f97064001ee5:/app# nslookup shop.pro.localhost
Server: 127.0.0.11
Address: 127.0.0.11#53
Non-authoritative answer:
shop.pro.localhost canonical name = other.pro.localhost.
Name: other.pro.localhost
Address: 127.0.0.1
--------
root@f97064001ee5:/app# cat /etc/resolv.conf
# This file can be edited; Docker Engine will not make further changes once it
# has been modified.
nameserver 127.0.0.11
options ndots:0
Notes: i dont want to use aliase for HTTP call as https://app
in my case due to other requirements
I dont why the behavior inside app
container is so weird for me:
- Why the
nslookup shop.pro.localhost
include something aboutother.pro.localhost
while i dont pass any specific to the container.
How can i solve the issues?
thank for your reading.
I have mentioned in the description