I would like to execute netstat inside a running docker container to see open TCP sockets and their statuses. But, on some of my docker containers, netstat is not available. Is
The two commands from @larsks answer merged into one-liner - no need to copy-paste the PID(s) (just replace container_name_or_id):
container_name_or_id
sudo nsenter -t $(docker inspect -f '{{.State.Pid}}' container_name_or_id) -n netstat