You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As described in my docker-compose.yml file below, I've defined three Docker containers: catalog-service, edge-service, and polar-keycloak. What I want is to be able to access polar-keycloak from my local machine's browser via http://host.docker.internal:8080, while simultaneously having catalog-service and edge-service access polar-keycloak via the same link (http://host.docker.internal:8080) within the Docker container cluster. To accomplish this, I configured host.docker.internal:host-gateway when defining catalog-service and edge-service in the docker-compose.yml file, but have not been successful.
Therefore, I started to troubleshoot the issue myself. I first attempted to run the docker network ls command:
➜ docker git:(master) ✗ docker network ls
NETWORK ID NAME DRIVER SCOPE
826180b597ee bridge bridge local
40581c0c5d46 host host local
25d6480ec121 none null local
Next, I ran the docker network inspect bridge command to view the network named bridge. The results are displayed as follows:
Subsequently, I ran the docker compose up -d polar-keycloak catalog-service edge-service command to launch these three docker containers. Immediately afterwards, I executed the docker network ls command again, and noticed that there was an additional network named docker_default in the results compared to before. I then ran the docker network inspect docker_default command to examine this docker_default network, and the results were as follows:
Finally, when I executed the docker exec -it catalog-service bash command to enter the catalog-service container, I used cat /etc/hosts to view the value of host.docker.internal. Surprisingly, its value was the Gateway of the bridge network (i.e., "Gateway": "172.17.0.1"), not the corresponding Gateway value of docker_default!
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Goal
As described in my
docker-compose.yml
file below, I've defined three Docker containers:catalog-service
,edge-service
, andpolar-keycloak
. What I want is to be able to accesspolar-keycloak
from my local machine's browser viahttp://host.docker.internal:8080
, while simultaneously havingcatalog-service
andedge-service
accesspolar-keycloak
via the same link (http://host.docker.internal:8080
) within the Docker container cluster. To accomplish this, I configuredhost.docker.internal:host-gateway
when definingcatalog-service
andedge-service
in thedocker-compose.yml
file, but have not been successful.docker-compose.yml
Environment
Docker version: 24.0.7
OS distro: Manjaro Linux
debugging
Therefore, I started to troubleshoot the issue myself. I first attempted to run the
docker network ls
command:Next, I ran the
docker network inspect bridge
command to view the network namedbridge
. The results are displayed as follows:docker network inspect bridge
Subsequently, I ran the
docker compose up -d polar-keycloak catalog-service edge-service
command to launch these three docker containers. Immediately afterwards, I executed thedocker network ls
command again, and noticed that there was an additional network nameddocker_default
in the results compared to before. I then ran thedocker network inspect docker_default
command to examine thisdocker_default
network, and the results were as follows:docker network inspect docker_default
Finally, when I executed the
docker exec -it catalog-service bash
command to enter thecatalog-service
container, I usedcat /etc/hosts
to view the value ofhost.docker.internal
. Surprisingly, its value was theGateway
of thebridge
network (i.e., "Gateway": "172.17.0.1"), not the correspondingGateway
value ofdocker_default
!cat /etc/hosts
Question
After explaining the above background information, how should I go about achieving my goal?
Beta Was this translation helpful? Give feedback.
All reactions