A NetHack4-Server Docker Image

If you've ever played NetHack, the beloved roguelike, then you'll be very familiar with the above image. It's the first message you receive when beginning a game and, due to the permadeath nature of roguelikes, you're likely to begin several games in a single session of nethack. Out of the few reincarnations of the classic game that have appeared in the last couple decades, I'm partial to NetHack4. It provides a nice polish to the original codebase as well as a practically endless list of improvements.

NetHack4's community offers a server to play on but I was interested in hosting my own. After a bit of digging, I was a little surprised that I didn't find a docker image for those who'd like to host their own server. So I created one here!

The most notable aspect of the NetHack4's stack is its use of inetd. I hadn't previously encountered this tool but its been heavily used in the past as a sort of "superserver" which routes Internet requests by spawning other processes, and its main purpose is to conserve server resources by only requiring one daemon to be running to route requests. By passing the -i option to inetd on runtime, the process runs in the foreground and therefore docker can attach to this process on docker run.

You can also use the image as a way to play locally or to connect to a server. Do this by running something like this docker run --entrypoint /app/nethack4 -it kenforthewin/nethack4-server. And here's how to connect to my server: