Getting started
This guide builds the sculkworm container locally, starts two throwaway Minecraft Java Edition status backends using minecraft-protocol, writes a routes file, runs sculkworm, pings both hostnames, reloads routes with SIGHUP, inspects the structured logs, and shuts everything down.
Every command runs in a terminal on the host. Each command block is followed by the output you see. Values in angle brackets, like <container id>, or ephemeral client port numbers change on every run.
The walkthrough publishes the relay on 127.0.0.1:25595 so it does not collide with any local Minecraft server on port 25565. In production, publish -p 25565:25565 and drop --add-host.
Prerequisites#
- Docker Engine
- Node.js 22.18 or later and
npm(for the two throwaway backends and the status ping client)
1. Build the container image#
The prebuilt image at ghcr.io/yellowumbrelladev/sculkworm is not published yet. Build the image locally from crates/sculkworm (or pass crates/sculkworm from the repository root):
docker build -t sculkworm crates/sculkwormThe build compiles a static Linux musl binary and packages it into a non-root distroless image. It finishes with:
=> => naming to docker.io/library/sculkworm:latest2. Start two local Minecraft status backends#
Create a working directory and install minecraft-protocol pinned to 1.68.0:
mkdir -p sculkworm-demo/config
cd sculkworm-demo
cat > package.json <<'EOF'
{
"name": "sculkworm-demo",
"private": true,
"type": "module",
"dependencies": {
"minecraft-protocol": "1.68.0"
}
}
EOF
npm install --no-audit --no-fundSave backends.mjs to start two offline-mode Minecraft 1.21.4 status responders on ports 25581 and 25582 with distinct MOTDs:
cat > backends.mjs <<'EOF'
import mc from 'minecraft-protocol';
const servers = [
{ port: 25581, motd: 'Survival backend' },
{ port: 25582, motd: 'Creative backend' },
];
for (const { port, motd } of servers) {
const server = mc.createServer({
'online-mode': false,
host: '0.0.0.0',
port,
version: '1.21.4',
motd,
});
server.on('listening', () => {
console.log(`listening on 0.0.0.0:${port} (${motd})`);
});
}
EOFStart both backends in the background and confirm they are listening:
node backends.mjs &
BACKENDS_PID=$!listening on 0.0.0.0:25581 (Survival backend)
listening on 0.0.0.0:25582 (Creative backend)3. Write the routes file and start sculkworm#
Write config/routes.json mapping two hostnames to the two local backends via host.docker.internal:
cat > config/routes.json <<'EOF'
{
"routes": {
"survival.play.example": "host.docker.internal:25581",
"creative.play.example": "host.docker.internal:25582"
}
}
EOFStart the sculkworm container with ./config mounted read-only at /etc/sculkworm. Mounting the directory (rather than the single file) lets atomic file replacements become visible inside the container on SIGHUP:
docker run -d --name sculkworm \
--add-host=host.docker.internal:host-gateway \
-p 127.0.0.1:25595:25565 \
-v "$PWD/config:/etc/sculkworm:ro" \
sculkworm<container id>Check the startup log:
docker logs sculkwormlevel=info event=listening addr=0.0.0.0:25565 routes=24. Ping both hostnames and an unknown hostname#
Save ping.mjs, which connects to 127.0.0.1:25595 while sending the requested hostname in the Minecraft 1.21.4 Handshake packet:
cat > ping.mjs <<'EOF'
import net from 'node:net';
import mc from 'minecraft-protocol';
const [, , serverHost, relayPort = '25595'] = process.argv;
const status = await mc.ping({
host: serverHost,
port: Number(relayPort),
version: '1.21.4',
connect: (client) => {
const socket = net.connect(Number(relayPort), '127.0.0.1');
client.setSocket(socket);
client.emit('connect');
},
});
console.log(JSON.stringify({ host: serverHost, version: status.version.name, motd: status.description.text }));
EOFPing survival.play.example:
node ping.mjs survival.play.example 25595{"host":"survival.play.example","version":"1.21.4","motd":"Survival backend"}Ping creative.play.example:
node ping.mjs creative.play.example 25595{"host":"creative.play.example","version":"1.21.4","motd":"Creative backend"}Ping a hostname not listed in routes.json. sculkworm closes the connection with zero bytes written:
node ping.mjs unknown.play.example 25595Error: Connection closed before the server sent a status response5. Hot-reload routes with SIGHUP#
Add a third hostname (lobby.play.example) by writing a temporary file and replacing config/routes.json atomically, then send SIGHUP to the container:
cat > config/routes.json.tmp <<'EOF'
{
"routes": {
"survival.play.example": "host.docker.internal:25581",
"creative.play.example": "host.docker.internal:25582",
"lobby.play.example": "host.docker.internal:25581"
}
}
EOF
mv config/routes.json.tmp config/routes.json
docker kill --signal=HUP sculkwormsculkwormPing the newly added hostname without restarting the container:
node ping.mjs lobby.play.example 25595{"host":"lobby.play.example","version":"1.21.4","motd":"Survival backend"}6. Shut down and inspect the full logs#
Stop the container gracefully (SIGTERM), inspect every log line emitted during the walkthrough, and clean up:
docker stop sculkworm
docker logs sculkwormlevel=info event=listening addr=0.0.0.0:25565 routes=2
level=info event=route host=survival.play.example target=host.docker.internal:25581 intent=status protocol=769 peer=172.17.0.1:59278
level=info event=closed host=survival.play.example target=host.docker.internal:25581 bytes_up=45 bytes_down=145 peer=172.17.0.1:59278
level=info event=route host=creative.play.example target=host.docker.internal:25582 intent=status protocol=769 peer=172.17.0.1:59282
level=info event=closed host=creative.play.example target=host.docker.internal:25582 bytes_up=45 bytes_down=145 peer=172.17.0.1:59282
level=info event=unknown_host host=unknown.play.example peer=172.17.0.1:55140
level=info event=reloaded routes=3
level=info event=route host=lobby.play.example target=host.docker.internal:25581 intent=status protocol=769 peer=172.17.0.1:55154
level=info event=closed host=lobby.play.example target=host.docker.internal:25581 bytes_up=42 bytes_down=145 peer=172.17.0.1:55154
level=info event=shutdownRemove the container and stop the local backends:
docker rm sculkworm
kill "$BACKENDS_PID"sculkwormNext steps#
- Read Configuration for every
SCULKWORM_*environment variable and route validation error. - Read Deploying for Docker Compose,
SIGHUPreload error handling, and TCP proxy behavior. - Read Security model before exposing sculkworm to the public internet.