Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions docs/misc/autoscale/autoscale.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

# Autoscaling (sleep when idle)

Autoscaling (sometimes called *sleeping*, *scale to zero* or *wake on join*) is the pattern of stopping a Minecraft server when nobody is playing and starting it again when someone tries to connect with the intention of saving resources when the server is not in use (e.g., on a VPS with limited CPU/RAM or a home server).

## mc-router

[mc-router](https://github.com/itzg/mc-router) is a Minecraft-aware router/multiplexer.

- Routes players by the hostname they connect with (useful for multiple servers behind one port)
- Can auto-start a backend container on join and stop it again after an idle timeout

Examples:

- See the mc-router section in [Examples](../examples.md#mc-router-with-auto-scale)

## Lazymc

[Lazymc](https://github.com/timvisee/lazymc) can keep a server “asleep” until a player connects. With Docker it’s commonly used via [lazymc-docker-proxy](https://github.com/joesturge/lazymc-docker-proxy).

- Players connect to the proxy; the proxy starts/stops the server container
- Usually requires a static IP for the Minecraft container on a user-defined network

Example:

- See the Lazymc section in [Examples](../examples.md#lazymc-put-your-minecraft-server-to-rest-when-idle)

## Lazytainer

[Lazytainer](https://github.com/vmorganp/Lazytainer) starts/stops containers based on network traffic.

- Uses packet thresholds + inactivity timeouts (not Minecraft hostname aware)
- Can be triggered by port scans/pings in noisy environments

Example:

- See the Lazytainer section in [Examples](../examples.md#lazytainer-stop-minecraft-container-based-on-traffic)


42 changes: 42 additions & 0 deletions docs/misc/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,48 @@ services:

[Source](https://github.com/itzg/docker-minecraft-server/blob/master/examples/geyser/docker-compose.yml)


## mc-router with auto-scale

Using [mc-router](https://github.com/itzg/mc-router) in front of one or multiple Minecraft server containers allows you to route players based on the hostname they use to connect.

With `AUTO_SCALE_UP` and `AUTO_SCALE_DOWN` enabled, mc-router can automatically start a target server when a player connects and stop it again after a period of inactivity.

```yaml title="compose.yaml"
services:
router:
image: itzg/mc-router
environment:
IN_DOCKER: true
AUTO_SCALE_DOWN: true
AUTO_SCALE_UP: true
AUTO_SCALE_DOWN_AFTER: 2h
AUTO_SCALE_ASLEEP_MOTD: "Server is asleep. Join again to wake it up!"
ports:
- "25565:25565"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro

vanilla:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
labels:
mc-router.host: "vanilla.example.com"

paper:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
TYPE: PAPER
labels:
mc-router.host: "paper.example.com"
```

[Source](https://github.com/itzg/mc-router/blob/main/examples/docker-autoscale/compose-minimal.yml)

[More detailed example](https://github.com/itzg/mc-router/blob/main/examples/docker-autoscale/compose.yml)
Comment on lines +68 to +70
Copy link

Copilot AI Dec 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Source links point to the external mc-router repository, but the examples are now part of this repository at examples/mc-router-autoscale/. The links should point to the local examples to be consistent with other examples in this file (e.g., line 28 and 187). The Source link should point to https://github.com/itzg/docker-minecraft-server/blob/master/examples/mc-router-autoscale/compose-minimal.yml and the detailed example should point to https://github.com/itzg/docker-minecraft-server/blob/master/examples/mc-router-autoscale/compose.yml.

Suggested change
[Source](https://github.com/itzg/mc-router/blob/main/examples/docker-autoscale/compose-minimal.yml)
[More detailed example](https://github.com/itzg/mc-router/blob/main/examples/docker-autoscale/compose.yml)
[Source](https://github.com/itzg/docker-minecraft-server/blob/master/examples/mc-router-autoscale/compose-minimal.yml)
[More detailed example](https://github.com/itzg/docker-minecraft-server/blob/master/examples/mc-router-autoscale/compose.yml)

Copilot uses AI. Check for mistakes.

## Lazymc - Put your Minecraft server to rest when idle

With [lazymc-docker-proxy](https://github.com/joesturge/lazymc-docker-proxy) you are able to use [lazymc](https://github.com/timvisee/lazymc) with the minecraft container.
Expand Down
27 changes: 27 additions & 0 deletions examples/mc-router-autoscale/compose-minimal.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Source: https://github.com/itzg/mc-router/blob/main/examples/docker-autoscale/compose-minimal.yml
services:
router:
image: itzg/mc-router
environment:
IN_DOCKER: true
AUTO_SCALE_DOWN: true
AUTO_SCALE_UP: true
AUTO_SCALE_DOWN_AFTER: 2h
AUTO_SCALE_ASLEEP_MOTD: "Server is asleep. Join again to wake it up!"
ports:
- "25565:25565"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
vanilla:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
labels:
mc-router.host: "vanilla.example.com"
paper:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
TYPE: PAPER
labels:
mc-router.host: "paper.example.com"
50 changes: 50 additions & 0 deletions examples/mc-router-autoscale/compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Source: https://github.com/itzg/mc-router/blob/main/examples/docker-autoscale/compose.yml
# This is a verbose example with comments and explanations for configuring auto-scaling behavior
# for Docker backend servers. See compose-minimal.yml for a simple minimal example.
services:
router:
image: itzg/mc-router
environment:
IN_DOCKER: true
# Global auto-scaling settings for all docker-backend servers
# Settings can be overridden per-backend using labels
# as shown in the backend services below (except for AUTO_SCALE_DOWN_AFTER which is global only)
# Enable auto-scaling down after inactivity for all backends by default
AUTO_SCALE_DOWN: true
# Enable auto-scaling up after player join for all backends by default
AUTO_SCALE_UP: true
# Time of inactivity after which to scale down (default: 10m) - Global only setting
AUTO_SCALE_DOWN_AFTER: 2h
# MOTD to show when server is asleep (default: empty string - don't show MOTD, show server offline instead)
AUTO_SCALE_ASLEEP_MOTD: "Server is asleep. Join again to wake it up!"
ports:
- "25565:25565"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
vanilla:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
labels:
# If global auto scaling settings are enabled, this backend will
# auto-scale without any additional auto-scale related configuration
mc-router.host: "vanilla.example.com"
fabric:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
TYPE: FABRIC
labels:
mc-router.host: "fabric.example.com"
# Disable auto-scaling for this backend specifically
mc-router.auto-scale-up: false
mc-router.auto-scale-down: false
paper:
image: itzg/minecraft-server
environment:
EULA: "TRUE"
TYPE: PAPER
labels:
mc-router.host: "paper.example.com"
# Override asleep MOTD for this backend
mc-router.auto-scale-asleep-motd: "Paper is folded. Join to unfold!"