Skip to content

dstmodders/docker-terraria-server

Repository files navigation

docker-terraria-server

Official Size TShock Size CI Build

Terraria Logo

Supported tags and respective Dockerfile links

Overview

Docker images for the Terraria game servers, including official and community TShock variants, emphasizing pure vanilla experience by default.

Quickstart

To begin, the simplest method is to clone this repository and execute Docker Compose from within either the official or tshock directory. This will automatically handle the pulling, creation, and mounting of all necessary components for you:

Step 1/4. Clone the repository and move into the corresponding directory

For Official server:

$ git clone https://github.com/dstmodders/docker-terraria-server.git
$ cd ./docker-terraria-server/official/

For TShock server:

$ git clone https://github.com/dstmodders/docker-terraria-server.git
$ cd ./docker-terraria-server/tshock/

Step 2/4. Start the server

$ docker compose up

All the server data, including the world and server settings, will be stored within the ./data/ directory.

Step 3/4. Attach to send server commands

$ docker compose attach terraria

Tip

To detach, use CTRL + P and then CTRL + Q.

Step 4/4. Stop the server

$ docker compose down

Once you've tested everything successfully, you can move the example ./docker-compose.yml into any directory of your choice and edit it according to your specific needs. Remember to also move the ./data/ directory if you wish to preserve your existing world and server settings.

For more detailed usage instructions, continue reading the next Usage chapter.

Usage

Official

Important

By default, the official Terraria server stores worlds in /home/terraria/.local/share/Terraria/Worlds/. We have changed the default path to /data/worlds/ instead to simplify the mounting process.

Docker Run (official)

To pull the latest official server:

$ docker pull dstmodders/terraria-server:latest
# or
$ docker pull ghcr.io/dstmodders/terraria-server:latest

Tip

See tags for a list of all available versions.

Shell/Bash (Linux & macOS)
$ docker run --rm -it -v "$(pwd):/data/" -p 7777:7777 dstmodders/terraria-server
The same, but with default environment variables

$ docker run --rm -it -v "$(pwd):/data/" -p 7777:7777 \
    -e DEBUG_ENTRYPOINT=0 \
    -e DISABLE_COLORS=0 \
    -e DISABLE_SUMMARY=0 \
    -e TZ=UTC \
    -e TERRARIA_AUTOCREATE=3 \
    -e TERRARIA_BANLIST=/data/banlist.txt \
    -e TERRARIA_DIFFICULTY=0 \
    -e TERRARIA_LANGUAGE='en-US' \
    -e TERRARIA_MAXPLAYERS=8 \
    -e TERRARIA_MOTD="Please don't cut the purple trees!" \
    -e TERRARIA_NPCSTREAM=60 \
    -e TERRARIA_PASSWORD='' \
    -e TERRARIA_PORT=7777 \
    -e TERRARIA_PRIORITY=1 \
    -e TERRARIA_SECURE=1 \
    -e TERRARIA_SEED='' \
    -e TERRARIA_UPNP=1 \
    -e TERRARIA_WORLD=/data/worlds/World.wld \
    -e TERRARIA_WORLDNAME=World \
    -e TERRARIA_WORLDPATH=/data/worlds/ \
    -e TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZEN=2 \
    -e TERRARIA_JOURNEYPERMISSION_GODMODE=2 \
    -e TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGE=2 \
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZEN=2 \
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTH=2 \
    -e TERRARIA_JOURNEYPERMISSION_SETDIFFICULTY=2 \
    -e TERRARIA_JOURNEYPERMISSION_SETSPAWNRATE=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDAWN=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDUSK=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETFROZEN=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHT=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETNOON=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETSPEED=2 \
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETFROZEN=2 \
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTH=2 \
    -e TERRARIA_ANNOUNCEMENTBOXRANGE='' \
    -e TERRARIA_CONFIG=/data/config.txt \
    -e TERRARIA_DISABLEANNOUNCEMENTBOX='' \
    -e TERRARIA_FORCEPRIORITY='' \
    -e TERRARIA_IP='' \
    -e TERRARIA_LOBBY='' \
    -e TERRARIA_STEAM=0 \
    dstmodders/terraria-server

CMD (Windows)
> docker run --rm -it -v "%CD%:/data/" -p 7777:7777 dstmodders/terraria-server
The same, but with default environment variables

> docker run --rm -it -v "%CD%:/data/" -p 7777:7777 ^
    -e DEBUG_ENTRYPOINT=0 ^
    -e DISABLE_COLORS=0 ^
    -e DISABLE_SUMMARY=0 ^
    -e TZ=UTC ^
    -e TERRARIA_AUTOCREATE=3 ^
    -e TERRARIA_BANLIST=/data/banlist.txt ^
    -e TERRARIA_DIFFICULTY=0 ^
    -e TERRARIA_LANGUAGE="en-US" ^
    -e TERRARIA_MAXPLAYERS=8 ^
    -e TERRARIA_MOTD="Please don't cut the purple trees!" ^
    -e TERRARIA_NPCSTREAM=60 ^
    -e TERRARIA_PASSWORD="" ^
    -e TERRARIA_PORT=7777 ^
    -e TERRARIA_PRIORITY=1 ^
    -e TERRARIA_SECURE=1 ^
    -e TERRARIA_SEED="" ^
    -e TERRARIA_UPNP=1 ^
    -e TERRARIA_WORLD=/data/worlds/World.wld ^
    -e TERRARIA_WORLDNAME=World ^
    -e TERRARIA_WORLDPATH=/data/worlds/ ^
    -e TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZEN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_GODMODE=2 ^
    -e TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGE=2 ^
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZEN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTH=2 ^
    -e TERRARIA_JOURNEYPERMISSION_SETDIFFICULTY=2 ^
    -e TERRARIA_JOURNEYPERMISSION_SETSPAWNRATE=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDAWN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDUSK=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETFROZEN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHT=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETNOON=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETSPEED=2 ^
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETFROZEN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTH=2 ^
    -e TERRARIA_ANNOUNCEMENTBOXRANGE="" ^
    -e TERRARIA_CONFIG=/data/config.txt ^
    -e TERRARIA_DISABLEANNOUNCEMENTBOX="" ^
    -e TERRARIA_FORCEPRIORITY="" ^
    -e TERRARIA_IP="" ^
    -e TERRARIA_LOBBY="" ^
    -e TERRARIA_STEAM=0 ^
    dstmodders/terraria-server

PowerShell (Windows)
PS:\> docker run --rm -it -v "${PWD}:/data/" -p 7777:7777 dstmodders/terraria-server
The same, but with default environment variables

PS:\> docker run --rm -it -v "${PWD}:/data/" -p 7777:7777 `
    -e DEBUG_ENTRYPOINT=0 `
    -e DISABLE_COLORS=0 `
    -e DISABLE_SUMMARY=0 `
    -e TZ=UTC `
    -e TERRARIA_AUTOCREATE=3 `
    -e TERRARIA_BANLIST=/data/banlist.txt `
    -e TERRARIA_DIFFICULTY=0 `
    -e TERRARIA_LANGUAGE='en-US' `
    -e TERRARIA_MAXPLAYERS=8 `
    -e TERRARIA_MOTD="Please don't cut the purple trees!" `
    -e TERRARIA_NPCSTREAM=60 `
    -e TERRARIA_PASSWORD='' `
    -e TERRARIA_PORT=7777 `
    -e TERRARIA_PRIORITY=1 `
    -e TERRARIA_SECURE=1 `
    -e TERRARIA_SEED='' `
    -e TERRARIA_UPNP=1 `
    -e TERRARIA_WORLD=/data/worlds/World.wld `
    -e TERRARIA_WORLDNAME=World `
    -e TERRARIA_WORLDPATH=/data/worlds/ `
    -e TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZEN=2 `
    -e TERRARIA_JOURNEYPERMISSION_GODMODE=2 `
    -e TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGE=2 `
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZEN=2 `
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTH=2 `
    -e TERRARIA_JOURNEYPERMISSION_SETDIFFICULTY=2 `
    -e TERRARIA_JOURNEYPERMISSION_SETSPAWNRATE=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDAWN=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDUSK=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETFROZEN=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHT=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETNOON=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETSPEED=2 `
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETFROZEN=2 `
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTH=2 `
    -e TERRARIA_ANNOUNCEMENTBOXRANGE='' `
    -e TERRARIA_CONFIG=/data/config.txt `
    -e TERRARIA_DISABLEANNOUNCEMENTBOX='' `
    -e TERRARIA_FORCEPRIORITY='' `
    -e TERRARIA_IP='' `
    -e TERRARIA_LOBBY='' `
    -e TERRARIA_STEAM=0 `
    dstmodders/terraria-server

Tip

To stop the container, use CTRL + C.

The commands above will run the server interactively in the foreground, allowing you to send commands as you would normally do when running the server binary on your host. If you prefer to run it non-interactively in the background, you can simply remove the -it flags and add the -d flag instead to run it in the detached mode: docker run -d.

Respectively, when running the server non-interactively in the background, you would also want to send commands non-interactively. For this purpose our container provides the following FIFO files for you to utilize:

  • /tmp/input
  • /tmp/output

You can send your server commands to the /tmp/input file, where each line will be recognized by the server as user input. Regarding /tmp/output, it may not always be necessary, as you can typically read output from the standard stdout using docker logs. However, it can be useful if you plan to create custom scripts.

The commands below will run the server non-interactively in the background. As an example, we'll also include instructions on reading output and sending input non-interactively.

Shell/Bash (Linux & macOS)
$ docker run --rm --name=terraria -d -v "$(pwd):/data/" -p 7777:7777 dstmodders/terraria-server # start
$ docker logs terraria # read output
$ docker exec terraria /bin/sh -c "echo 'help' >> /tmp/input" # send input
$ docker stop terraria # stop
The same, but with default environment variables

$ docker run --rm --name=terraria -d -v "$(pwd):/data/" -p 7777:7777 \
    -e DEBUG_ENTRYPOINT=0 \
    -e DISABLE_COLORS=0 \
    -e DISABLE_SUMMARY=0 \
    -e TZ=UTC \
    -e TERRARIA_AUTOCREATE=3 \
    -e TERRARIA_BANLIST=/data/banlist.txt \
    -e TERRARIA_DIFFICULTY=0 \
    -e TERRARIA_LANGUAGE='en-US' \
    -e TERRARIA_MAXPLAYERS=8 \
    -e TERRARIA_MOTD="Please don't cut the purple trees!" \
    -e TERRARIA_NPCSTREAM=60 \
    -e TERRARIA_PASSWORD='' \
    -e TERRARIA_PORT=7777 \
    -e TERRARIA_PRIORITY=1 \
    -e TERRARIA_SECURE=1 \
    -e TERRARIA_SEED='' \
    -e TERRARIA_UPNP=1 \
    -e TERRARIA_WORLD=/data/worlds/World.wld \
    -e TERRARIA_WORLDNAME=World \
    -e TERRARIA_WORLDPATH=/data/worlds/ \
    -e TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZEN=2 \
    -e TERRARIA_JOURNEYPERMISSION_GODMODE=2 \
    -e TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGE=2 \
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZEN=2 \
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTH=2 \
    -e TERRARIA_JOURNEYPERMISSION_SETDIFFICULTY=2 \
    -e TERRARIA_JOURNEYPERMISSION_SETSPAWNRATE=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDAWN=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDUSK=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETFROZEN=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHT=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETNOON=2 \
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETSPEED=2 \
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETFROZEN=2 \
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTH=2 \
    -e TERRARIA_ANNOUNCEMENTBOXRANGE='' \
    -e TERRARIA_CONFIG=/data/config.txt \
    -e TERRARIA_DISABLEANNOUNCEMENTBOX='' \
    -e TERRARIA_FORCEPRIORITY='' \
    -e TERRARIA_IP='' \
    -e TERRARIA_LOBBY='' \
    -e TERRARIA_STEAM=0 \
    dstmodders/terraria-server
$ docker logs terraria
$ docker exec terraria /bin/sh -c "echo 'help' >> /tmp/input"
$ docker stop terraria

CMD (Windows)
> docker run --rm --name=terraria -d -v "%CD%:/data/" -p 7777:7777 dstmodders/terraria-server & REM start
> docker logs terraria & REM read output
> docker exec terraria /bin/sh -c "echo 'help' >> /tmp/input" & REM send input
> docker stop terraria & REM stop
The same, but with default environment variables

> docker run --rm --name=terraria -d -v "%CD%:/data/" -p 7777:7777 ^
    -e DEBUG_ENTRYPOINT=0 ^
    -e DISABLE_COLORS=0 ^
    -e DISABLE_SUMMARY=0 ^
    -e TZ=UTC ^
    -e TERRARIA_AUTOCREATE=3 ^
    -e TERRARIA_BANLIST=/data/banlist.txt ^
    -e TERRARIA_DIFFICULTY=0 ^
    -e TERRARIA_LANGUAGE="en-US" ^
    -e TERRARIA_MAXPLAYERS=8 ^
    -e TERRARIA_MOTD="Please don't cut the purple trees!" ^
    -e TERRARIA_NPCSTREAM=60 ^
    -e TERRARIA_PASSWORD="" ^
    -e TERRARIA_PORT=7777 ^
    -e TERRARIA_PRIORITY=1 ^
    -e TERRARIA_SECURE=1 ^
    -e TERRARIA_SEED="" ^
    -e TERRARIA_UPNP=1 ^
    -e TERRARIA_WORLD=/data/worlds/World.wld ^
    -e TERRARIA_WORLDNAME=World ^
    -e TERRARIA_WORLDPATH=/data/worlds/ ^
    -e TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZEN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_GODMODE=2 ^
    -e TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGE=2 ^
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZEN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTH=2 ^
    -e TERRARIA_JOURNEYPERMISSION_SETDIFFICULTY=2 ^
    -e TERRARIA_JOURNEYPERMISSION_SETSPAWNRATE=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDAWN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDUSK=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETFROZEN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHT=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETNOON=2 ^
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETSPEED=2 ^
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETFROZEN=2 ^
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTH=2 ^
    -e TERRARIA_ANNOUNCEMENTBOXRANGE="" ^
    -e TERRARIA_CONFIG=/data/config.txt ^
    -e TERRARIA_DISABLEANNOUNCEMENTBOX="" ^
    -e TERRARIA_FORCEPRIORITY="" ^
    -e TERRARIA_IP="" ^
    -e TERRARIA_LOBBY="" ^
    -e TERRARIA_STEAM=0 ^
    dstmodders/terraria-server
> docker logs terraria
> docker exec terraria /bin/sh -c "echo 'help' >> /tmp/input"
> docker stop terraria

PowerShell (Windows)
PS:\> docker run --rm --name=terraria -d -v "${PWD}:/data/" -p 7777:7777 dstmodders/terraria-server # start
PS:\> docker logs terraria # read output
PS:\> docker exec terraria /bin/sh -c "echo 'help' >> /tmp/input" # send input
PS:\> docker stop terraria # stop
The same, but with default environment variables

PS:\> docker run --rm --name=terraria -d -v "${PWD}:/data/" -p 7777:7777 `
    -e DEBUG_ENTRYPOINT=0 `
    -e DISABLE_COLORS=0 `
    -e DISABLE_SUMMARY=0 `
    -e TZ=UTC `
    -e TERRARIA_AUTOCREATE=3 `
    -e TERRARIA_BANLIST=/data/banlist.txt `
    -e TERRARIA_DIFFICULTY=0 `
    -e TERRARIA_LANGUAGE='en-US' `
    -e TERRARIA_MAXPLAYERS=8 `
    -e TERRARIA_MOTD="Please don't cut the purple trees!" `
    -e TERRARIA_NPCSTREAM=60 `
    -e TERRARIA_PASSWORD='' `
    -e TERRARIA_PORT=7777 `
    -e TERRARIA_PRIORITY=1 `
    -e TERRARIA_SECURE=1 `
    -e TERRARIA_SEED='' `
    -e TERRARIA_UPNP=1 `
    -e TERRARIA_WORLD=/data/worlds/World.wld `
    -e TERRARIA_WORLDNAME=World `
    -e TERRARIA_WORLDPATH=/data/worlds/ `
    -e TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZEN=2 `
    -e TERRARIA_JOURNEYPERMISSION_GODMODE=2 `
    -e TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGE=2 `
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZEN=2 `
    -e TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTH=2 `
    -e TERRARIA_JOURNEYPERMISSION_SETDIFFICULTY=2 `
    -e TERRARIA_JOURNEYPERMISSION_SETSPAWNRATE=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDAWN=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETDUSK=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETFROZEN=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHT=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETNOON=2 `
    -e TERRARIA_JOURNEYPERMISSION_TIME_SETSPEED=2 `
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETFROZEN=2 `
    -e TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTH=2 `
    -e TERRARIA_ANNOUNCEMENTBOXRANGE='' `
    -e TERRARIA_CONFIG=/data/config.txt `
    -e TERRARIA_DISABLEANNOUNCEMENTBOX='' `
    -e TERRARIA_FORCEPRIORITY='' `
    -e TERRARIA_IP='' `
    -e TERRARIA_LOBBY='' `
    -e TERRARIA_STEAM=0 `
    dstmodders/terraria-server
PS:\> docker logs terraria
PS:\> docker exec terraria /bin/sh -c "echo 'help' >> /tmp/input"
PS:\> docker stop terraria

Docker Compose (official)

Note

The provided environment variables are all optional, as they use the default values. We've added them to our example just so that you wouldn't have to dig for them in supported environment variables.

version: '3.7'

services:
  terraria:
    image: 'dstmodders/terraria-server:latest'
    stdin_open: true
    tty: true
    ports:
      - '7777:7777'
    volumes:
      - './data/:/data/:rw'
    environment:
      # system parameters
      DEBUG_ENTRYPOINT: 0
      DISABLE_COLORS: 0
      DISABLE_SUMMARY: 0
      TZ: UTC
      # general parameters
      TERRARIA_AUTOCREATE: 3
      TERRARIA_BANLIST: /data/banlist.txt
      TERRARIA_DIFFICULTY: 0
      TERRARIA_LANGUAGE: en-US
      TERRARIA_MAXPLAYERS: 8
      TERRARIA_MOTD: "Please don't cut the purple trees!"
      TERRARIA_NPCSTREAM: 60
      TERRARIA_PASSWORD: ''
      TERRARIA_PORT: 7777
      TERRARIA_PRIORITY: 1
      TERRARIA_SECURE: 1
      TERRARIA_SEED: ''
      TERRARIA_UPNP: 1
      TERRARIA_WORLD: /data/worlds/World.wld
      TERRARIA_WORLDNAME: World
      TERRARIA_WORLDPATH: /data/worlds/
      # journey parameters
      TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZEN: 2
      TERRARIA_JOURNEYPERMISSION_GODMODE: 2
      TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGE: 2
      TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZEN: 2
      TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTH: 2
      TERRARIA_JOURNEYPERMISSION_SETDIFFICULTY: 2
      TERRARIA_JOURNEYPERMISSION_SETSPAWNRATE: 2
      TERRARIA_JOURNEYPERMISSION_TIME_SETDAWN: 2
      TERRARIA_JOURNEYPERMISSION_TIME_SETDUSK: 2
      TERRARIA_JOURNEYPERMISSION_TIME_SETFROZEN: 2
      TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHT: 2
      TERRARIA_JOURNEYPERMISSION_TIME_SETNOON: 2
      TERRARIA_JOURNEYPERMISSION_TIME_SETSPEED: 2
      TERRARIA_JOURNEYPERMISSION_WIND_SETFROZEN: 2
      TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTH: 2
      # command-line parameters
      TERRARIA_ANNOUNCEMENTBOXRANGE: ''
      TERRARIA_CONFIG: /data/config.txt
      TERRARIA_DISABLEANNOUNCEMENTBOX: ''
      TERRARIA_FORCEPRIORITY: ''
      TERRARIA_IP: ''
      TERRARIA_LOBBY: ''
      TERRARIA_STEAM: 0

TShock

Important

By default, the TShock server stores worlds in /home/terraria/.local/share/Terraria/Worlds/. The TShock server configurations are stored in /opt/tshock/tshock/. We have changed the default paths to point to /data/ instead to simplify the mounting process.

Docker Run (tshock)

To pull the latest community TShock server:

$ docker pull dstmodders/terraria-server:tshock
# or
$ docker pull ghcr.io/dstmodders/terraria-server:tshock

Tip

See tags for a list of all available versions.

Shell/Bash (Linux & macOS)
$ docker run --rm -it -v "$(pwd):/data/" -p 7777:7777 -p 7878:7878 dstmodders/terraria-server:tshock
The same, but with default environment variables

$ docker run --rm -it -v "$(pwd):/data/" -p 7777:7777 -p 7878:7878 \
    -e DEBUG_ENTRYPOINT=0 \
    -e DISABLE_COLORS=0 \
    -e DISABLE_SUMMARY=0 \
    -e TZ=UTC \
    -e TSHOCK_ADDITIONALPLUGINS=/data/plugins/ \
    -e TSHOCK_CONFIGPATH=/data/ \
    -e TSHOCK_CRASHDIR=/data/crashes/ \
    -e TSHOCK_LOGPATH=/data/logs/ \
    -e TSHOCK_WORLDSELECTPATH=/data/worlds/ \
    dstmodders/terraria-server:tshock

CMD (Windows)
> docker run --rm -it -v "%CD%:/data/" -p 7777:7777 -p 7878:7878 dstmodders/terraria-server:tshock
The same, but with default environment variables

> docker run --rm -it -v "%CD%:/data/" -p 7777:7777 -p 7878:7878 ^
    -e DEBUG_ENTRYPOINT=0 ^
    -e DISABLE_COLORS=0 ^
    -e DISABLE_SUMMARY=0 ^
    -e TZ=UTC ^
    -e TSHOCK_ADDITIONALPLUGINS=/data/plugins/ ^
    -e TSHOCK_CONFIGPATH=/data/ ^
    -e TSHOCK_CRASHDIR=/data/crashes/ ^
    -e TSHOCK_LOGPATH=/data/logs/ ^
    -e TSHOCK_WORLDSELECTPATH=/data/worlds/ ^
    dstmodders/terraria-server:tshock

PowerShell (Windows)
PS:\> docker run --rm -it -v "${PWD}:/data/" -p 7777:7777 -p 7878:7878 dstmodders/terraria-server:tshock
The same, but with default environment variables

PS:\> docker run --rm -it -v "${PWD}:/data/" -p 7777:7777 -p 7878:7878 `
    -e DEBUG_ENTRYPOINT=0 `
    -e DISABLE_COLORS=0 `
    -e DISABLE_SUMMARY=0 `
    -e TZ=UTC `
    -e TSHOCK_ADDITIONALPLUGINS=/data/plugins/ `
    -e TSHOCK_CONFIGPATH=/data/ `
    -e TSHOCK_CRASHDIR=/data/crashes/ `
    -e TSHOCK_LOGPATH=/data/logs/ `
    -e TSHOCK_WORLDSELECTPATH=/data/worlds/ `
    dstmodders/terraria-server:tshock

Docker Compose (tshock)

Note

The provided environment variables are all optional, as they use the default values. We've added them to our example just so that you wouldn't have to dig for them in supported environment variables.

version: '3.7'

services:
  terraria:
    image: 'dstmodders/terraria-server:tshock'
    stdin_open: true
    tty: true
    ports:
      - '7777:7777'
      - '7878:7878' # REST API
    volumes:
      - './data/:/data/:rw'
    environment:
      # system parameters
      DEBUG_ENTRYPOINT: 0
      DISABLE_COLORS: 0
      DISABLE_SUMMARY: 0
      TZ: UTC
      # command-line parameters
      TSHOCK_ADDITIONALPLUGINS: /data/plugins/
      TSHOCK_CONFIGPATH: /data/
      TSHOCK_CRASHDIR: /data/crashes/
      TSHOCK_LOGPATH: /data/logs/
      TSHOCK_WORLDSELECTPATH: /data/worlds/

Supported environment variables

System

System environment variables are unrelated to the Terraria server and are exclusive to the system.

Name Image Default Description
DEBUG_ENTRYPOINT official
tshock
0 Toggles debug messages in the entrypoint
DISABLE_COLORS official
tshock
0 Toggles colored output
DISABLE_SUMMARY official
tshock
0 Toggles configurations summary before starting the server
TERRARIA_TSHOCK_VERSION tshock 5.2.0 Shows TShock version
TERRARIA_VERSION official
tshock
1.4.4.9 Shows Terraria version
TZ official
tshock
UTC Sets the timezone.

General

General environment variables represent the Terraria server features that can be configured through the default configuration file /data/config.txt. While most have corresponding command-line parameters in the server binary, they are primarily set through the configuration file instead.

Name Image Default Description
TERRARIA_AUTOCREATE official 3

Creates a new world if none is found. World size is specified by:

  • 1 (small)
  • 2 (medium)
  • 3 (large)
TERRARIA_BANLIST official /data/banlist.txt Sets the location of the banlist.
TERRARIA_DIFFICULTY official 0

Sets the world difficulty when using autocreate. Options:

  • 0 (normal)
  • 1 (expert)
  • 2 (master)
  • 3 (journey)
TERRARIA_LANGUAGE official en-US

Sets the server language from its language code. Available codes:

  • en-US (English)
  • de-DE (German)
  • it-IT (Italian)
  • fr-FR (French)
  • es-ES (Spanish)
  • ru-RU (Russian)
  • zh-Hans (Chinese)
  • pt-BR (Portuguese)
  • pl-PL (Polish)
TERRARIA_MAXPLAYERS official 8 Sets the max number of players allowed on a server. Value must be between 1 and 255.
TERRARIA_MOTD official Please don't cut the purple trees! Sets the message of the day.
TERRARIA_NPCSTREAM official 60 Reduces enemy skipping but increases bandwidth usage. The lower the number the less skipping will happen, but more data is sent. 0 is off.
TERRARIA_PASSWORD official Sets the server password.
TERRARIA_PORT official 7777 Sets the port number.
TERRARIA_PRIORITY official 1

Sets the default system priority:

  • 0 (realtime)
  • 1 (high)
  • 2 (above normal)
  • 3 (normal)
  • 4 (below normal)
  • 5 (idle)
TERRARIA_SECURE official 1 Toggles additional cheat protection.
TERRARIA_SEED official Sets the world seed when using autocreate.
TERRARIA_UPNP official 1 Toggles automatic ports forwarding with uPNP.
TERRARIA_WORLDNAME official World Sets the name of the world when using autocreate.
TERRARIA_WORLDPATH official /data/worlds/ Sets the directory where world files will be stored.
TERRARIA_WORLD official /data/worlds/World.wld Loads a world and automatically starts the server.

Journey permissions

Journey permissions environment variables are related to individual power permissions under journey difficulty:

  • 0 (locked for everyone)
  • 1 (can only be changed by host)
  • 2 (can be changed by everyone)

Only applicable when difficulty is set to 3 (journey) like when setting the TERRARIA_DIFFICULTY environment variable to 3. They are only configurable through the server configuration file.

Name Image Default
TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZEN official 2
TERRARIA_JOURNEYPERMISSION_GODMODE official 2
TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGE official 2
TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZEN official 2
TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTH official 2
TERRARIA_JOURNEYPERMISSION_SETDIFFICULTY official 2
TERRARIA_JOURNEYPERMISSION_SETSPAWNRATE official 2
TERRARIA_JOURNEYPERMISSION_TIME_SETDAWN official 2
TERRARIA_JOURNEYPERMISSION_TIME_SETDUSK official 2
TERRARIA_JOURNEYPERMISSION_TIME_SETFROZEN official 2
TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHT official 2
TERRARIA_JOURNEYPERMISSION_TIME_SETNOON official 2
TERRARIA_JOURNEYPERMISSION_TIME_SETSPEED official 2
TERRARIA_JOURNEYPERMISSION_WIND_SETFROZEN official 2
TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTH official 2

Command-line

Command-line environment variables represent features unique to Terraria server binary parameters.

Name Image Default Description
TERRARIA_ANNOUNCEMENTBOXRANGE official Sets the "Announcement Box" text messaging range in pixels, -1 for serverwide announcements.
TERRARIA_CONFIG official /data/config.txt Sets the configuration file path.
TERRARIA_DISABLEANNOUNCEMENTBOX official Disables the text announcements that "Announcement Box" makes when pulsed from wire.
TERRARIA_FORCEPRIORITY official

Sets the process priority for this task:

  • 0 (realtime)
  • 1 (high)
  • 2 (above normal)
  • 3 (normal)
  • 4 (below normal)
  • 5 (idle)

If this is used the priority setting will be ignored.

TERRARIA_IP official Sets the IP address for the server to listen on.
TERRARIA_LOBBY official

Allows only friends to join the server or sets it to private if Steam is enabled:

  • friends
  • private
TERRARIA_STEAM official 0 Toggles Steam support.
TSHOCK_ADDITIONALPLUGINS tshock /data/plugins/ Sets the additional plugins directory path.
TSHOCK_CONFIGPATH tshock /data/ Sets the configurations directory path.
TSHOCK_CRASHDIR tshock /data/crashes/ Sets the crashes directory path.
TSHOCK_LOGPATH tshock /data/logs/ Sets the logs directory path.
TSHOCK_WORLDSELECTPATH tshock /data/worlds/ Sets the worlds directory path.

Supported architectures

Image Architecture(s)
official linux/amd64
tshock linux/amd64

Supported build arguments

Name Image Default Description
TERRARIA_VERSION official
tshock
1.4.4.9 Sets Terraria version
TERRARIA_TSHOCK_VERSION tshock 5.2.0 Sets TShock version

Build

To build images locally:

$ docker build --file='./official/Dockerfile' --tag='dstmodders/terraria-server:latest' .
$ docker build --file='./tshock/Dockerfile' --tag='dstmodders/terraria-server:tshock' .

License

Released under the MIT License.