Skip to content

Simple Docker container to test if a port works using a Golang server

License

Notifications You must be signed in to change notification settings

qdm12/port-checker

Repository files navigation

Port Checker with Docker

12.8MB container to check a TCP port works with a Golang HTTP server

Build status Docker Pulls Docker Stars

GitHub last commit GitHub commit activity GitHub issues

Features

  • Listening address configurable
  • Root URL configurable - useful to test reverse proxies
  • HTTP server responding with information on your client:
    • Client IP (public or private)
    • Browser and version
    • Device type
    • OS and version
  • Lightweight program of around 8MB
  • Docker image is compatible with amd64, 386, arm64, arm/v6, arm/v7, s390x, ppc64le and riscv64
  • Standalone binaries pre-built for each release for Linux (amd64, 386, arm64), Darwin (amd64, arm64) and Windows (amd64, 386, arm64)

Standalone binary

You can download one of the binaries attached with each Github release. For example:

wget -qO port-checker https://github.com/qdm12/port-checker/releases/download/v0.1.0/port-checker_0.1.0_linux_amd64
chmod +x port-checker
./port-checker --listening-address=":8000" --root-url="/"

You can build the binary for a specific platform if it's not listed using for example:

CGO_ENALBED=0 GOARCH=amd64 go build -o port-checker github.com/qdm12/port-checker

Docker image

To test port 1234, use:

docker run --rm -p 1234:8000/tcp qmcgaw/port-checker

To test port 1234 internally, use:

docker run --rm -e LISTENING_ADDRESS=":1234" qmcgaw/port-checker

💁 There are also image tags, such as :v0.1.0, corresponding to each tagged release.

Options

Environment variable Flag Default Possible values Description
LISTENING_ADDRESS --listening-address :8000 Valid listening address TCP address to listen on internally
ROOT_URL --root-url / URL path string Used if it is running behind a proxy for example

TO DOs

  • Use GeoLite database and Google Maps to show the location
  • Add CSS to the HTML template
  • Precise external mapped port to check it can access itself at start
  • Unit testing
  • Notifications (Pushbullet, email, etc. ?)
  • UDP port check, see this