Getting rootless container internal IP
Rootless containers with podman uses slirp4netns plugin, so to get the ip the first thing we need it to know the container's network namespace path:
So the network namespace path for the container is /run/user/1000/netns/cni-64e3d3b6-091e-7ea8-8959-39d4ea6e6746.There are several namespaces that were created:
As slirp4netns plugin is used we can also get the namespace path:
To open a shell in the namespace we need to use the nsenter command, but we can do it using podman:
As you can see you are running a shell inside the namespace and you are mapped as root user (be carefull!!!). Using the ip a command we can see that the IP assigned to that container is 10.0.2.100.Do not forget to close the shell:
This example is quite easy due to there is only one container running. If we have more containers running as rootless we will have more slirp3netns process so we will have to identify the right one for which we want to identify the internal IP.





Comments
Post a Comment