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 Image size Image version

Join Slack channel GitHub last commit GitHub commit activity GitHub issues

Features

  • HTTP lightweight server responding with information on your client:
    • Client IP (public or private)
    • Browser and version
    • Device type
    • OS and version
  • Compatible with amd64, 386, armv6, armv7 and arm64 v8 cpu architectures

Setup

  1. To test port 1234, use:

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

    To test port 1234 internally, use:

    docker run -it --rm -e LISTENING_PORT=1234 qmcgaw/port-checker
  2. With a client, access http://localhost:1234. You can also port forward with your router to test it is accessible remotely.

Binary

You can also download one of the binaries on the Github releases. 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
# Usage with
./port-checker -help

Environment variables

Environment variable Default Possible values Description
LISTENING_PORT 8000 1025 to 65535 TCP port to listen on internally
ROOT_URL / URL path string Used if it is running behind a proxy for example

Development

Using VSCode and Docker

  1. Install Docker
    • On Windows, share a drive with Docker Desktop and have the project on that partition
  2. With Visual Studio Code, install the remote containers extension
  3. In Visual Studio Code, press on F1 and select Remote-Containers: Open Folder in Container...
  4. Your dev environment is ready to go!... and it's running in a container 👍

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