What is linux equivalent of “host.docker.internal”

前端 未结 9 1184
面向向阳花
面向向阳花 2020-12-02 09:37

On Mac and Windows it is possible to use docker.for.mac.host.internal (replaces docker.for.mac.localhost) and docker.for.win.host.int

9条回答
  •  感动是毒
    2020-12-02 10:11

    For linux there isn't a default DNS name for the host machine. This can be verified by running the command:

    docker run -it alpine cat /etc/hosts
    

    This feature has been requested, however wasn't implemented. You can check this issue. As discussed you can use the following command to find the IP of the host from the container.

    netstat -nr | grep '^0\.0\.0\.0' | awk '{print $2}'
    

    Alternatively, you can provide the host ip to the run command via docker run --add-host dockerHost: ...

提交回复
热议问题