When using Docker, ESTABLISHED connections don't appear in netstat

前端 未结 2 1734
面向向阳花
面向向阳花 2020-12-31 06:58

I have a docker container running on RHEL 7 with Docker 1.7.0. The program which running in this container listens for TCP connections on port 5000. In my Dockerfile I put t

2条回答
  •  北海茫月
    2020-12-31 07:02

    You can either do:

    docker exec  netstat -tan | grep ESTABLISHED
    

    or if you don't have netstat in your docker image:

    docker inspect -f '{{.State.Pid}}'  # note the PID
    sudo nsenter -t  -n netstat | grep ESTABLISHED
    

    nsenter is part of util-linux package. (plagiarized @larsks)

提交回复
热议问题