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
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ This does not require the RCON connection to be exposed.
docker exec factorio rcon /h
```

### Server health

Regular and rootless images check server responsiveness using the read-only `rcon /players count` command, with a five-second timeout. RCON does not need to be published, and the check does not affect achievements.

```shell
docker inspect --format '{{.State.Health.Status}}' factorio
```

The default interval is 30 seconds, with three retries and a five-minute startup grace period. For large saves or heavy mod sets, adjust Compose `healthcheck.start_period`, `interval` and `retries` to allow for loading and save pauses. Use `healthcheck.disable: true` (or `docker run --no-healthcheck`) if you intentionally disable or replace RCON.

Docker reports `starting`, `healthy` or `unhealthy`; it does not automatically restart unhealthy containers. Use this status with your monitoring tool. The check does not test external UDP connectivity or provide an HTTP endpoint. Keep the Docker API and RCON private.

### Upgrading

Before upgrading backup the save. It's easy to make a save in the client.
Expand Down
2 changes: 2 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,6 @@ COPY --from=rcon-builder /src/rcon /bin/rcon

VOLUME /factorio
EXPOSE $PORT/udp $RCON_PORT/tcp
HEALTHCHECK --interval=30s --timeout=10s --start-period=5m --retries=3 CMD ["/docker-healthcheck.sh"]

ENTRYPOINT ["/docker-entrypoint.sh"]
2 changes: 2 additions & 0 deletions docker/Dockerfile.rootless
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,6 @@ EXPOSE $PORT/udp $RCON_PORT/tcp
# Run as non-root user (UID 1000 is common for the first user in rootless containers)
USER 1000:1000

HEALTHCHECK --interval=30s --timeout=10s --start-period=5m --retries=3 CMD ["/docker-healthcheck.sh"]

ENTRYPOINT ["/docker-entrypoint.sh"]
9 changes: 9 additions & 0 deletions docker/files/docker-healthcheck.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -euo pipefail

# Avoid invoking the RCON client before startup has created its password file.
[[ -s "${CONFIG:?}/rconpw" && -r "$CONFIG/rconpw" ]] || exit 1

# A TCP connection alone cannot detect failed authentication or a stuck server.
response=$(timeout 5s rcon /players count) || exit 1
[[ "$response" =~ ^Players\ \([0-9]+\): ]]
Loading