0

When a docker container is starting, its explosed port would be mapped to a port of the docker host.

Of cause, I can use the specified mapped port, but, I don't want to do so.

Is there a method to get the ip and port of the docker host in a docker container when it is starting.

kino lucky
  • 1,365
  • 4
  • 15
  • 24
  • 2
    possible duplicate of [How to get the ip address of the docker host from inside a docker container](http://stackoverflow.com/questions/22944631/how-to-get-the-ip-address-of-the-docker-host-from-inside-a-docker-container) – Mark O'Connor Aug 06 '14 at 13:16
  • Why not use the mapped port? That is how Docker is supposed work. – Mark O'Connor Aug 06 '14 at 13:17

1 Answers1

0

The simplest way to get it is through ifconfig (interface docker0) from the host

From inside a docker, the following command from a docker:

ip -4 route show default | cut -d" " -f3

Ashok
  • 3,190
  • 15
  • 31