Skip to content
Lucas Nicodemus edited this page Jan 26, 2025 · 7 revisions

Docker Setup

In order to run TShock in a docker container, you would need to have mountpoints for

  • /tshock (TShock config files, logs and crash reports)
  • /worlds
  • /plugins
  • /server (optional, if you want to mount TShock's cwd)

These folders can be mounted using -v <host_folder>:<container>

Open ports can also be passed through using -p <host_port>:<container_port>.

  • 7777 for Terraria
  • 7878 for TShock's REST API

For Example:

# Building the image using buildx and loading it into docker
docker buildx build -t tshock:latest --load .

# Running the image
docker run -p 7777:7777 -p 7878:7878 \
           -v /home/cider/tshock/:/tshock \
           -v /home/cider/.local/share/Terraria/Worlds:/worlds \
           -v /home/cider/tshock/plugins:/plugins \
           --rm -it tshock:latest \
           -world /worlds/backflip.wld -motd "OMFG DOCKER"

Building for Other Platforms

Using docker buildx, you could build multi-platform images for TShock.

For Example:

# Building the image using buildx and loading it into docker
docker buildx build -t tshock:linux-arm64 --platform linux/arm64 --load .

# Running the image
docker run -p 7777:7777 -p 7878:7878 \
           -v /home/cider/tshock/:/tshock \
           -v /home/cider/.local/share/Terraria/Worlds:/worlds \
           -v /home/cider/tshock/plugins:/plugins \
           --rm -it tshock:linux-arm64 \
           -world /worlds/backflip.wld -motd "ARM64 ftw"

Using Docker Compose

If you have Docker Compose installed, you can skip building the image explicitly, and rather use a docker-compose.yml file like so:

services:
  terraria:
    build:
      context: https://github.com/Pryaxis/TShock.git
      args:
        TARGETPLATFORM: linux/amd64
    container_name: terraria
    restart: unless-stopped
    volumes:
      - "./tshock/:/tshock"
      - "./worlds:/worlds"
      - "./plugins:/plugins"
      - "/etc/localtime:/etc/localtime:ro"
    ports:
      - "7777:7777"
      - "7878:7878" # can be removed if you don't use the REST service
    command: -world /worlds/my_world.wld

To run the server interactively, for example to generate a world, use docker compose run --rm terraria (without the command: for now). Then, you can use docker compose up -d to run it in the background, and have it automatically restart with your host system.

Clone this wiki locally