Denis Machard

My technical gists

Infrastructure architect by profession but always consider himself as a developer and an open source enthusiast.
@github @mastodon @rss

This post shows how to execute network commands (like ip a, ping, etc.) within a container’s network namespace without installing any additional tools.

  1. Get the Process ID (PID) of the Container. Use the docker inspect command to retrieve the PID of the container. This will output the PID of the container’s main process
sudo docker inspect -f '{{.State.Pid}}' <container_name_or_id>
  1. Use the nsenter command to enter the network namespace of the container, Replace with the PID you obtained before.
sudo nsenter --net=/proc/<PID>/ns/net
propulsed by hugo and hugo-theme-gists