Hi,
I’m trying to find a way to list the exact ip of a container created with rancher 1.6. Normally in docker you would list that using docker inspect --format '{{ .NetworkSettings.IPAddress }}, which in Rancher context doesn’t exist, as Rancher uses different values, i.e. Labels: io.rancher.container.ip.
Of course, I tried using docker inspect --format '{{ .Labels.io.rancher.container.ip }}' , but it doesn’t work. Any ideas how I can go about this?
Thank you for the reply. Can you explain what index does in this context and why I couldn’t extract the values without it? How are they related to the upper functions such as Config or Labels?
Index looks up the given key (2nd arg) in the given map (1st arg). This works when the key contains dots, while “.Labels.io.rancher.container.ip” is looking for the key “io” in “Labels”, then the key “rancher” in that, then “container”, then “ip”, and finds nothing.
I understand, so it would have meant that there’s a hierarchy between ‘io’, ‘rancher’ and so on, when it obviously isnt’, it’s just the name of the variable. Right, thanks for the explanation.