Skip to content

Instantly share code, notes, and snippets.

@roundand
Last active June 20, 2024 12:36
Show Gist options
  • Save roundand/245ce5e174d245f8cfa933a25940c276 to your computer and use it in GitHub Desktop.
Save roundand/245ce5e174d245f8cfa933a25940c276 to your computer and use it in GitHub Desktop.
Minimal Busybox-compatible echo server (also good for Alpine)

Using nc (aka netcat) as a commonly available solution (but this syntax only tested for Alpine):

nc -lkp 8088 -e /bin/cat

nb:

  • -l for listen
  • -k to keep running for multiple calls (unavailable on busybox)
  • -p for port parameter
  • -e for program to execute (in the absence of a filename, cat echoes stdin to stdout)

To run with Docker:

docker run -d --rm -p 8088:8088 alpine nc -lkp 8088 -e /bin/cat 

To use, next run:

nc localhost 8088

This connects us in client mode. Type something, hit enter and observe the response.

Hello?
Hello?
You're a bot!
You're a bot!

Hit Ctrl-c to exit. With the "-l" flag you can repeat the sequence, without the "-k" flag the server nc would stop listening at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment