GlitchNode Blog

Devlogs, performance notes, and behind-the-scenes of running game servers.

2025-08-07

On-Demand Provisioning with Dockerode + Fastify

FastifyDockerodeBackend
On-Demand Provisioning with Dockerode + Fastify

Provisioning is a single API call away. The Fastify route validates input, selects a port, and asks Dockerode to create + start the container.

What we set at create time

  • Image: Java or Bedrock, chosen by product
  • Volumes: bind host /mc-servers/{name} to container /data
  • Ports: Java 25565/tcp, Bedrock 19132/udp with host port mapping
  • Env: EULA=TRUE, SERVER_NAME, MAX_PLAYERS, etc.
  • Restart: unless-stopped for resilience

Graceful stop & logs

  • Stop: container.stop() after sending say/save via exec if needed
  • Logs (Java): exec cat /data/logs/latest.log and stream back

Health & stats

  • Stats endpoint aggregates docker.stats (CPU %, RSS) + host load average
  • Used by scheduler to place new servers on the best node