How to I get the public hostname or ip address the containerd would binded to?

I am trying to figureout from where to get the hostname of a running docker container that was started using docker-py.

Based on presence of DOCKER_HOST= file the started docker container my be on a remove machine and not on the localhost (machine running docker-py code).

I looked inside the container object and I was not able to find any information that would be of use for as 'HostIp': '0.0.0.0' is the remote docker host.

I need an IP or DNS name of the remote machine.

I know that I could start parsing DOCKER_HOST myself and “guess” that but this would not really be a reliable way of doing it, especially as there are multiple protocols involved: ssh:// and tcp:// at least.

I guess it should be an API based way of getting this information.

PS. We would assume that the docker host does not have firewall.

Source: StackOverflow