Operations 5 min read

Monitor Docker Container Network Connections with check-docker-connection

This guide explains what the check-docker-connection tool does, its required environment, command‑line options, how to run it inside a Docker container, and provides step‑by‑step examples for monitoring single or multiple containers and displaying the top N containers by connection count.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Monitor Docker Container Network Connections with check-docker-connection

What Is check-docker-connection?

The check-docker-connection utility monitors Docker containers' network connections, reporting the number of TCP and UDP connections for each specified container. Users can select containers by ID or name, or request the top N containers with the most connections, and the results are shown in a table.

Key Features

Shows ESTABLISHED, TIME_WAIT, FIN_WAIT2, CLOSE_WAIT, LISTEN, SYN_SENT, SYN_RECV states

Counts UDP connections

Environment Requirements

Docker must be installed on the host.

The host needs netstat and nsenter (usually provided by the net-tools and util-linux packages).

Command‑Line Arguments

-c

: Comma‑separated list of container IDs or names to monitor. -n: Show the top N containers with the highest connection counts.

Note: -c and -n cannot be used together.

Running check-docker-connection

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --pid=host --net=host --privileged 80imike/check-docker-connection

Important considerations:

The tool needs access to the Docker socket ( /var/run/docker.sock).

The --pid=host and --net=host flags let the container share the host’s process and network namespaces.

The --privileged flag enables the use of nsenter inside the container.

Usage Examples

Example 1 – Monitor a Single Container

To monitor a container named traefik:

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --pid=host --net=host --privileged 80imike/check-docker-connection -c traefik

This prints all network connection states for the traefik container.

Example 2 – Monitor Multiple Containers

To monitor both traefik and splayer containers:

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --pid=host --net=host --privileged 80imike/check-docker-connection -c traefik,splayer

The output shows the network connections for both containers.

Example 3 – Show Top 3 Containers by Connection Count

To display the three containers with the most connections:

$ docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --pid=host --net=host --privileged 80imike/check-docker-connection -n 3

The command lists the network connection states for the top three containers.

These examples demonstrate how to quickly monitor Docker containers' network connections for performance analysis and troubleshooting.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLIDockerLinuxContainer
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.