I recently had to look up my Hetzner VM's IP in a private network I'd set up from inside a Docker container. My initial set up was a bit clunky passing the host IP addresses during deployment but there's an easy way to look it up:
$ curl http://169.254.169.254/hetzner/v1/metadata/private-networks
- ip: 10.0.0.2
alias_ips: [10.0.0.3, 10.0.0.4]
interface_num: 1
mac_address: 86:00:00:2a:7d:e0
network_id: 1234
network_name: nw-test1
network: 10.0.0.0/8
subnet: 10.0.0.0/24
gateway: 10.0.0.1
- ip: 192.168.0.2
alias_ips: []
interface_num: 2
mac_address: 86:00:00:2a:7d:e1
network_id: 4321
network_name: nw-test2
network: 192.168.0.0/16
subnet: 192.168.0.0/24
gateway: 192.168.0.1
For some odd reason, they chose to return YAML but you should be able to extract the IP address you're looking for from this response.
You can lookup other useful information like the region, availability zone, etc too: https://docs.hetzner.cloud/#server-metadata