A custom configuration can be loaded by mounting the file to: /data/openttd.cfg
Available options are listed in the official wiki and github.
If the environment variable LOAD_AUTOSAVE is set, the latest autosave present in /data/save/autosave/
will be loaded.
A template save file can be loaded by mounting the file to: /data/save/template.sav
The file will be ignored if LOAD_AUTOSAVE is set and an autosave file is present in /data/save/autosave/
.
A custom user or group id can be defined by setting the environment variable PUID
or PGID
, e.g. PUID=2000
or PGID=3000
.
To download online content in a running container, use the content
command:
content update
content state ITL Houses
content select 54540301
content download
For online content to be loaded from persistent storage, make sure the content file is:
Present in the mounted volume, e.g.
/data/content_download/newgrf/54540301-ITL_Houses-2.1.tar
And configured in the /data/openttd.cfg
config file, e.g.
[newgrf]
54540301|F7CDD4F730E4F3EE87100CE42E5070AE|itl_houses-2.1/itl_houses.grf = 0 0 0
If no port mapping is configured for the container, a server with server_game_type = public
will still register with the Game Coordinator and attempt to use Connection type: Behind NAT
to establish connections with clients.
Defaults
docker run
docker run --interactive --tty --rm \
-p "3979:3979/tcp" \
-p "3979:3979/udp" \
n0thub/openttd:latest
docker compose
version: '3'
services:
openttd:
image: n0thub/openttd:latest
ports:
- "3979:3979/tcp"
- "3979:3979/udp"
Custom config
docker run
docker run --interactive --tty --rm \
-p "3979:3979/tcp" \
-p "3979:3979/udp" \
-v "${PWD}/example.cfg:/data/openttd.cfg" \
n0thub/openttd:latest
docker compose
version: '3'
services:
openttd:
image: n0thub/openttd:latest
ports:
- "3979:3979/tcp"
- "3979:3979/udp"
volumes:
- ./example.cfg:/data/openttd.cfg
Persistent storage mount
docker run
docker run --interactive --tty --rm \
-p "3979:3979/tcp" \
-p "3979:3979/udp" \
-v "${PWD}/data/:/data/" \
n0thub/openttd:latest
docker compose
version: '3'
services:
openttd:
image: n0thub/openttd:latest
ports:
- "3979:3979/tcp"
- "3979:3979/udp"
volumes:
- ./data/:/data/
Load latest autosave
docker run
docker run --interactive --tty --rm \
-p "3979:3979/tcp" \
-p "3979:3979/udp" \
-v "${PWD}/data/:/data/" \
-e LOAD_AUTOSAVE="true" \
n0thub/openttd:latest
docker compose
version: '3'
services:
openttd:
image: n0thub/openttd:latest
ports:
- "3979:3979/tcp"
- "3979:3979/udp"
volumes:
- ./data/:/data/
environment:
- LOAD_AUTOSAVE="true"
Load template save
docker run
docker run --interactive --tty --rm \
-p "3979:3979/tcp" \
-p "3979:3979/udp" \
-v "${PWD}/template.sav:/data/save/template.sav" \
n0thub/openttd:latest
docker compose
version: '3'
services:
openttd:
image: n0thub/openttd:latest
ports:
- "3979:3979/tcp"
- "3979:3979/udp"
volumes:
- ./template.sav:/data/save/template.sav
Custom user or group id
docker run
docker run --interactive --tty --rm \
-p "3979:3979/tcp" \
-p "3979:3979/udp" \
-v "${PWD}/data/:/data/" \
-e PUID=2000 \
-e PGID=3000 \
n0thub/openttd:latest
docker compose
version: '3'
services:
openttd:
image: n0thub/openttd:latest
ports:
- "3979:3979/tcp"
- "3979:3979/udp"
volumes:
- ./data/:/data/
environment:
- PUID=2000
- PGID=3000
Combined options
docker run
docker run --interactive --tty --rm \
-p "3979:3979/tcp" \
-p "3979:3979/udp" \
-v "${PWD}/data/:/data/" \
-v "${PWD}/example.cfg:/data/openttd.cfg" \
-v "${PWD}/template.sav:/data/save/template.sav" \
-e PUID=2000 \
-e PGID=3000 \
-e LOAD_AUTOSAVE="true" \
n0thub/openttd:latest
docker compose
version: '3'
services:
openttd:
image: n0thub/openttd:latest
ports:
- "3979:3979/tcp"
- "3979:3979/udp"
volumes:
- ./data/:/data/
- ./example.cfg:/data/openttd.cfg
- ./template.sav:/data/save/template.sav
environment:
- PUID=2000
- PGID=3000
- LOAD_AUTOSAVE="true"
Arguments will be relayed to the OpenTTD process if supplied to the container:
docker run --rm n0thub/openttd:latest --help