---
title: "Run BattleSpades in Docker"
description: "Run the BattleSpades Ace of Spades server from the ghcr.io/kikots/battlespades container image: docker run, environment variables, data volume, custom config, Compose fleets and safe rollouts."
canonical: "https://www.aosplay.net/guides/server/docker"
markdown: "https://www.aosplay.net/docs/guides/server/docker.md"
last_updated: "2026-09-28"
section: "BattleSpades server hosting guides"
keywords: ["BattleSpades Docker","Ace of Spades server Docker","ghcr.io kikots battlespades","Ace of Spades docker compose"]
---

# Run BattleSpades in Docker

> Run the BattleSpades Ace of Spades server from the ghcr.io/kikots/battlespades container image: docker run, environment variables, data volume, custom config, Compose fleets and safe rollouts.

The official container image is the easiest way to run BattleSpades on a Linux VPS. Configuration comes from a few environment variables, all writable data lives in one volume, and the process drops to an unprivileged user before any game code runs.

## The image

| Property | Value |
| --- | --- |
| Registry | `ghcr.io/kikots/battlespades` |
| Tags | `main` (latest successful build of main), `sha-<commit>` (immutable, use for production), and `v…` release tags |
| Platform | `linux/amd64` |
| Built by | `.github/workflows/container.yml` — only after the complete test suite passes; images carry provenance and an SBOM |
| Base | `python:3.12-slim-bookworm`, compiled in a separate build stage |
| Exposed port | `27015/udp` |
| User | UID/GID `10001` (`battlespades`); only `/data` is writable |
| Entrypoint | `tini` → `scripts/container_init.sh` → `scripts/container_entrypoint.py` |

On start the entrypoint copies the image's `config.toml`, applies the environment variables below, writes the effective file to `/data/runtime/config.toml`, and starts the normal server. Logs go to `/data/logs/` and bans to `/data/bans.json`. The Windows-only Steam browser helper is always disabled inside the container.

## Quick start

**Run one server**

~~~bash
docker volume create battlespades-data

docker run -d --name battlespades --restart unless-stopped \
  -p 27015:27015/udp \
  -e BATTLESPADES_ADMIN_PASSWORD='replace-with-a-long-secret' \
  -e BATTLESPADES_SERVER_NAME='My AoS Server' \
  -e BATTLESPADES_MODE=ctf \
  -e BATTLESPADES_MAP=CastleWars \
  -e BATTLESPADES_REVIVAL_ENABLED=false \
  -v battlespades-data:/data \
  ghcr.io/kikots/battlespades:main

docker logs -f battlespades
~~~

- The admin password is **required** (12+ characters); the container refuses to start with the sample `changeme`.
- Publish the same UDP port inside and outside (`-p 27015:27015/udp`). To use another port, set `BATTLESPADES_PORT=27025` and publish `-p 27025:27025/udp`.
- `BATTLESPADES_REVIVAL_ENABLED=false` keeps a test container off the AoSPlay list. For a public server, see the listing variables below.
- Validate without starting: `docker run --rm ghcr.io/kikots/battlespades:main --check`.

**Probe it from the host (source checkout)**

~~~bash
python deploy/a2s_probe.py --host 127.0.0.1 --port 27015
~~~

## Environment variables

The image deliberately exposes a small, validated set of overrides. Values are checked (ranges, safe characters, map names never paths) and a bad value stops the container with a `BattleSpades container configuration error` message. Every other key comes from the config template.

_The complete generated reference table (environment) is on the [HTML page](https://www.aosplay.net/guides/server/docker); it is generated from the BattleSpades source._

## Make a container public

1. **Open UDP.** Allow the published UDP port in the VPS provider's firewall and the host firewall.
2. **First boot without a token.** Start with `AOS_PUBLIC_HOST` set to the node's public IPv4 and no `AOS_MASTER_WRITE_TOKEN`.
3. **Register on the node.** Run `deploy/register_server.py` on the game node once the A2S probe passes (see [Ports and public listing](https://www.aosplay.net/guides/server/network-and-listing#aosplay)).
4. **Recreate with the token.** Put the printed `aos_srv_…` token in `AOS_MASTER_WRITE_TOKEN` and recreate only that container.

**Extra variables for a listed server**

~~~bash
  -e BATTLESPADES_REGION=europe \
  -e AOS_PUBLIC_HOST=203.0.113.10 \
  -e AOS_MASTER_WRITE_TOKEN=aos_srv_... \
~~~

Behind a UDP relay (for example a Playit endpoint `147.185.221.26:56675` forwarding to the container's `27015/udp`), keep `BATTLESPADES_PORT=27015` and set `AOS_PUBLIC_HOST=147.185.221.26` and `AOS_PUBLIC_PORT=56675`. A2S keeps answering on the private socket while heartbeats and join tickets use the public endpoint.

## Use your own config.toml

To change keys the variables do not cover (rotation, game rules, bots, conduct…), mount a complete config file and point the template at it. The environment variables are still applied on top, Steam is still forced off, and `bans_path` is always `/data/bans.json`.

**Mount a template**

~~~bash
docker run -d --name battlespades --restart unless-stopped \
  -p 27015:27015/udp \
  -v "$PWD/my-config.toml:/config/config.toml:ro" \
  -e BATTLESPADES_CONFIG_TEMPLATE=/config/config.toml \
  -e BATTLESPADES_ADMIN_PASSWORD='replace-with-a-long-secret' \
  -v battlespades-data:/data \
  ghcr.io/kikots/battlespades:main
~~~

> **Runtime files: Results and reports live in /data.** The entrypoint rebases `[revival] results_path` (pending AoSPlay round results, `state/round-results.sqlite3`) and `[anticheat] report_path` (`logs/anticheat.jsonl`) under `/data`, so they survive container replacement even though the hardened Compose example mounts the application folder read-only. A relative path in your template is kept below `/data`; an absolute path is used as written.

## Several servers with Compose

`deploy/docker-compose.example.yml` in the repository runs three hardened servers (CTF on 27015, TDM on 27025, Zombie on 27035) from one image: read-only root filesystem, all Linux capabilities dropped, `no-new-privileges`, a 256-process limit, a 64 MB `/tmp`, and one named volume per server.

**First installation on a Linux node**

~~~bash
sudo git clone https://github.com/KikoTs/BattleSpades.git /opt/BattleSpades
cd /opt/BattleSpades
sudo cp deploy/.env.example deploy/.env
sudo chmod 600 deploy/.env
sudoedit deploy/.env     # SERVER_1..3_ADMIN_PASSWORD, AOS_PUBLIC_HOST, tokens

docker compose --env-file deploy/.env \
  -f deploy/docker-compose.example.yml up -d
~~~

The `.env` file (template: `deploy/.env.example`) holds `BATTLESPADES_IMAGE`, `SERVER_1_ADMIN_PASSWORD` … `SERVER_3_ADMIN_PASSWORD`, `AOS_PUBLIC_HOST`, optional `AOS_MASTER_URL`, `BATTLESPADES_IMAGE_TAG`, and `AOS_SERVER_1_TOKEN` … `AOS_SERVER_3_TOKEN`. Leave the tokens empty for the first boot, register each port, then fill them in and recreate only that service.

## Updating containers safely

Pin production to an immutable `sha-…` tag rather than `main`. `deploy/rollout.sh` pulls a tag, recreates one server at a time, and waits for a valid protocol-168 A2S reply before moving on; if a server fails that health gate the rollout stops and prints its recent logs.

**Roll the Compose fleet to a tested image**

~~~bash
cd /opt/BattleSpades
./deploy/rollout.sh sha-1a2b3c4
~~~

> **Players: A restart disconnects everyone on that server.** Deploy while servers are empty or announce it first with `/say`. The repository's workflow can also roll out automatically on each `main` push when the `AUTO_DEPLOY_GAME_NODE` variable and the SSH secrets are configured; protect the `game-production` environment if a human should approve each restart.

## Frequently asked questions

### Can I run the image on ARM?

The published image is `linux/amd64` only. On ARM hosts use a portable `linux-arm64` release or build the image yourself with `docker build`.

### Where are the logs?

`docker logs <container>` shows the console; files are in the volume under `/data/logs/`.

### How do I build the image myself?

From a checkout: `docker build --build-arg VCS_REF="$(git rev-parse HEAD)" --build-arg IMAGE_VERSION="$(cat VERSION)" -t battlespades:local .`

### Does the container support Steam browser listing?

No. The Steam helper needs Valve's Windows x86 runtime and is always disabled in the Linux image. AoSPlay listing works normally.

---

Source: [Run BattleSpades in Docker](https://www.aosplay.net/guides/server/docker)  
Ace of Spades Revival is an independent community project, not affiliated with the original publisher. Community Discord: https://discord.gg/aosbb
