How to get the IP address of the docker host from inside a docker container

后端 未结 24 1462
鱼传尺愫
鱼传尺愫 2020-11-22 06:41

As the title says. I need to be able to retrieve the IP address the docker hosts and the portmaps from the host to the container, and doing that inside of the container.

24条回答
  •  -上瘾入骨i
    2020-11-22 07:31

    So... if you are running your containers using a Rancher server, Rancher v1.6 (not sure if 2.0 has this) containers have access to http://rancher-metadata/ which has a lot of useful information.

    From inside the container the IP address can be found here: curl http://rancher-metadata/latest/self/host/agent_ip

    For more details see: https://rancher.com/docs/rancher/v1.6/en/rancher-services/metadata-service/

提交回复
热议问题