2025-08-07
On-Demand Provisioning with Dockerode + Fastify
FastifyDockerodeBackend

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, Bedrock19132/udpwith host port mapping - Env:
EULA=TRUE,SERVER_NAME,MAX_PLAYERS, etc. - Restart:
unless-stoppedfor resilience
Graceful stop & logs
- Stop:
container.stop()after sendingsay/save via exec if needed - Logs (Java):
execcat /data/logs/latest.logand 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