본문 바로가기
Docker

container netstat 확인하는 방법

by freesunny 2019. 10. 16.

container 의 PID 확인
# docker inspect -f '{{.State.Pid}}' container_id or container_name

해당 PID의 netstat 확인

# nsenter -t PID -n netstat

예제)

# docker ps
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS              PORTS                    NAMES
48ed5791585e        dockeropggredis_redis-slave2   "docker-entrypoint..."   2 years ago         Up 4 months         0.0.0.0:8002->6379/tcp   dockeropggredis_redis-slave2_1
a72d895ea6dc        dockeropggredis_redis-slave1   "docker-entrypoint..."   2 years ago         Up 4 months         0.0.0.0:8001->6379/tcp   dockeropggredis_redis-slave1_1
# docker inspect -f '{{.State.Pid}}' 48ed5791585e
1746
# nsenter -t 1746 -n netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 0.0.0.0:6379            0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.11:42577        0.0.0.0:*               LISTEN
#