# How to list container ip with docker inspect --format

**URL:** <https://forums.suse.com/t/how-to-list-container-ip-with-docker-inspect-format/13044>\
**Category:** Rancher 1.x\
**Created:** [January 18, 2019, 12:49pm UTC](https://forums.suse.com/t/how-to-list-container-ip-with-docker-inspect-format/13044 "2019-01-18T12:49:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinci](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vinci](https://forums.suse.com/u/vinci)\
**Post date:** [January 18, 2019, 12:49pm UTC](https://forums.suse.com/t/how-to-list-container-ip-with-docker-inspect-format/13044/1 "2019-01-18T12:49:48Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![superseb](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/superseb/32/2424_2.png) [@superseb](https://forums.suse.com/u/superseb)\
**Post date:** [January 19, 2019, 5:34am UTC](https://forums.suse.com/t/how-to-list-container-ip-with-docker-inspect-format/13044/2 "2019-01-19T05:34:42Z")

</div>

You can try something like:

```auto
docker inspect $container_id --format '{{ index .Config.Labels "io.rancher.container.ip"}}'

```

---

<div class="post-metadata">

**Author:** ![vinci](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vinci](https://forums.suse.com/u/vinci)\
**Post date:** [January 24, 2019, 12:11pm UTC](https://forums.suse.com/t/how-to-list-container-ip-with-docker-inspect-format/13044/3 "2019-01-24T12:11:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![vincent](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/vincent/32/7156_2.png) [@vincent](https://forums.suse.com/u/vincent)\
**Post date:** [January 24, 2019, 7:18pm UTC](https://forums.suse.com/t/how-to-list-container-ip-with-docker-inspect-format/13044/4 "2019-01-24T19:18:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![vinci](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vinci](https://forums.suse.com/u/vinci)\
**Post date:** [January 25, 2019, 9:20am UTC](https://forums.suse.com/t/how-to-list-container-ip-with-docker-inspect-format/13044/5 "2019-01-25T09:20:09Z")

</div>

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.
