Docker: any way to list open sockets inside a running docker container?

前端 未结 3 1701
遇见更好的自我
遇见更好的自我 2021-01-29 21:53

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

3条回答
  •  别那么骄傲
    2021-01-29 22:44

    The two commands from @larsks answer merged into one-liner - no need to copy-paste the PID(s) (just replace container_name_or_id):

    sudo nsenter -t $(docker inspect -f '{{.State.Pid}}' container_name_or_id) -n netstat
    

提交回复
热议问题