The problem is you're getting an object with index .NetworkSettings.Ports "1234/tcp" 0
and in string context that's producing { 1234}
which is a concatenation of the first value (an empty string) joined by a space and the second value which is 1234
. The index is returning an object. But it's getting stringified. You would never know that without inspecting the return of index
with json
.
You can see with
$ podman inspect evanrox --format '{{ json ( index .NetworkSettings.Ports "1234/tcp" 0 ) }}'
That the result is
{"HostIp":"","HostPort":"1234"}
From there you can go
$ podman inspect evanrox --format '{{ json ( index .NetworkSettings.Ports "1234/tcp" 0 ).HostPort }}'
And then you'll see "1234"
drop the json
, and you get it
$ podman inspect evanrox --format '{{ ( index .NetworkSettings.Ports "1234/tcp" 0 ).HostPort }}'