Background
I was trying to get the IP address of one of my podman containers.
I was using this command over and over with much pain (and no gain):
podman inspect -f '{{ .NetworkSettings.IPAddress }}' <container-name>
Journey to the Solution
Finally, after much frustration, I resorted to AI shameful face
ChatGPT told me this:
“The command podman inspect -f '{{ .NetworkSettings.IPAddress }}' <container-name>
doesn’t return the IP because, in Podman’s newer versions, container IP addresses are organized under specific networks (not directly under .NetworkSettings.IPAddress as in Docker). This means you need to query the IP address specifically for the network name in use.”
Then, it told me to run this kind of thing which gave me errors on the network name syntax and then finally gave me ‘no value’ output.
podman inspect -f '{{ .NetworkSettings.Networks.<network_name>.IPAddress }}' <container-name>
I also tried to remove the container completely with podman container rm -a
.
No go.
I tried pruning the containers with podman network prune
No go
I was pulling my hair out and then at some unknown point, I was reading something in the terminal and it seemed as though it was complaining about something related to a hyphen / dash.
The Solution
YOU CANNOT USE A PROJECT FOLDER WITH A HYPHEN IN IT IF YOU WANT TO BE ABLE TO RUN THIS COMMAND:
podman inspect project_01 -f '{{ .NetworkSettings.Network.project_01.projectnetwork }}'
So the solution is this: never create a podman project directory with a hyphen / dash in the name.
Once I changed the hyphen to an underscore, everything worked as expected!
Hope this helps.