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.