0

I recently changed my MAC and installed docker with Docker version 20.10.8, build 3967b7d and deployed some of SpringBoot Apps... they are accessible with localhost:port but not with below mentioned Docker HOST URLs like

  1. gateway.docker.internal:port
  2. host.docker.internal:port

In my old MAC I was able to access Docker container with URL gateway.docker.internal... Old Laptop is no more with me so cant put old Docker version...

I did docker inspect ... | grep Address also but the IP coming out of the command is also not working. It just waits there forever.

But what is the Docker HOST URL or IP for Docker version mentioned above.

Jaikrat
  • 1,124
  • 3
  • 24
  • 45
  • Please try with my solution at https://stackoverflow.com/a/61001152/418599 . – Antonio Petricca Sep 20 '21 at 07:16
  • `>export IP_ADDRESS=$(ip addr show | grep "\binet\b.*\bdocker0\b" | awk '{print $2}' | cut -d '/' -f 1) >echo $IP_ADDRESS`. Command is showing nothing on my terminal. – Jaikrat Sep 20 '21 at 07:46
  • Have you tried 172.17.0.1? – Hans Kilian Sep 20 '21 at 07:53
  • Yes @HansKilian ... it just wait there forever when hitting curl with this IP. – Jaikrat Sep 20 '21 at 07:55
  • also tried with below commands `docker container run -d -p 8091:8080 --add-host=host.docker.internal:172.17.0.1 --name third-instance -t 8ac980efcefc` and `docker container run -d -p 8091:8080 --add-host=host.docker.internal:host-gateway --name third-instance -t 8ac980efcefc`...but result is same in both...i.e.`curl: (6) Could not resolve host: host.docker.internal` – Jaikrat Sep 20 '21 at 07:59
  • What are you trying to connect to; from where? (Are you trying to connect _from_ the host _to_ one of the Spring Boot applications, or the reverse?) – David Maze Sep 20 '21 at 10:12
  • It's resolved now @DavidMaze. I am trying to connect to Spring Boot app deployed in my Docker, thru Docker Host URL or IP. – Jaikrat Sep 21 '21 at 16:35

1 Answers1

0

From @Amrut Prabhu How to access host port from docker container

The simplest option that worked for me was, I used the IP address of my machine on the local network(assigned by the router)

You can find this using the ifconfig command

e.g

ifconfig

en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        options=400<CHANNEL_IO>
        ether f0:18:98:08:74:d4 
        inet 192.168.178.63 netmask 0xffffff00 broadcast 192.168.178.255
        media: autoselect
        status: active
and then used the inet address. This worked for me to connect any ports on my machine.
Jaikrat
  • 1,124
  • 3
  • 24
  • 45