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/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 sendingsay
/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