Sign inSign up

dstmodders/terraria-server

By dstmodders

•Updated over 2 years ago

Dockerized Terraria official and TShock servers.

Image
0

2.7K

dstmodders/terraria-server repository overview

Terraria Logo

⁠Overview

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

⁠Official

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

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
⁠CMD (Windows)
> docker run --rm -it -v "%CD%:/data/" -p 7777:7777 dstmodders/terraria-server
⁠PowerShell (Windows)
PS:\> docker run --rm -it -v "${PWD}:/data/" -p 7777:7777 dstmodders/terraria-server

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
⁠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
⁠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
⁠Docker Compose (official)

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

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

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
⁠CMD (Windows)
> docker run --rm -it -v "%CD%:/data/" -p 7777:7777 -p 7878:7878 dstmodders/terraria-server:tshock
⁠PowerShell (Windows)
PS:\> docker run --rm -it -v "${PWD}:/data/" -p 7777:7777 -p 7878:7878 dstmodders/terraria-server:tshock
⁠Docker Compose (tshock)

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.

NameImageDefaultDescription
DEBUG_ENTRYPOINTofficial
tshock
0Toggles debug messages in the entrypoint
DISABLE_COLORSofficial
tshock
0Toggles colored output
DISABLE_SUMMARYofficial
tshock
0Toggles configurations summary before starting the server
TERRARIA_TSHOCK_VERSIONtshock5.2.0Shows TShock⁠ version
TERRARIA_VERSIONofficial
tshock
1.4.4.9Shows Terraria⁠ version
TZofficial
tshock
UTCSets 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.

NameImageDefaultDescription
TERRARIA_AUTOCREATEofficial3

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

  • 1 (small)
  • 2 (medium)
  • 3 (large)
TERRARIA_BANLISTofficial/data/banlist.txtSets the location of the banlist.
TERRARIA_DIFFICULTYofficial0

Sets the world difficulty when using autocreate. Options:

  • 0 (normal)
  • 1 (expert)
  • 2 (master)
  • 3 (journey)
TERRARIA_LANGUAGEofficialen-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_MAXPLAYERSofficial8Sets the max number of players allowed on a server. Value must be between 1 and 255.
TERRARIA_MOTDofficialPlease don't cut the purple trees!Sets the message of the day.
TERRARIA_NPCSTREAMofficial60Reduces enemy skipping but increases bandwidth usage. The lower the number the less skipping will happen, but more data is sent. 0 is off.
TERRARIA_PASSWORDofficialSets the server password.
TERRARIA_PORTofficial7777Sets the port number.
TERRARIA_PRIORITYofficial1

Sets the default system priority:

  • 0 (realtime)
  • 1 (high)
  • 2 (above normal)
  • 3 (normal)
  • 4 (below normal)
  • 5 (idle)
TERRARIA_SECUREofficial1Toggles additional cheat protection.
TERRARIA_SEEDofficialSets the world seed when using autocreate.
TERRARIA_UPNPofficial1Toggles automatic ports forwarding with uPNP.
TERRARIA_WORLDNAMEofficialWorldSets the name of the world when using autocreate.
TERRARIA_WORLDPATHofficial/data/worlds/Sets the directory where world files will be stored.
TERRARIA_WORLDofficial/data/worlds/World.wldLoads 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.

NameImageDefault
TERRARIA_JOURNEYPERMISSION_BIOMESPREAD_SETFROZENofficial2
TERRARIA_JOURNEYPERMISSION_GODMODEofficial2
TERRARIA_JOURNEYPERMISSION_INCREASEPLACEMENTRANGEofficial2
TERRARIA_JOURNEYPERMISSION_RAIN_SETFROZENofficial2
TERRARIA_JOURNEYPERMISSION_RAIN_SETSTRENGTHofficial2
TERRARIA_JOURNEYPERMISSION_SETDIFFICULTYofficial2
TERRARIA_JOURNEYPERMISSION_SETSPAWNRATEofficial2
TERRARIA_JOURNEYPERMISSION_TIME_SETDAWNofficial2
TERRARIA_JOURNEYPERMISSION_TIME_SETDUSKofficial2
TERRARIA_JOURNEYPERMISSION_TIME_SETFROZENofficial2
TERRARIA_JOURNEYPERMISSION_TIME_SETMIDNIGHTofficial2
TERRARIA_JOURNEYPERMISSION_TIME_SETNOONofficial2
TERRARIA_JOURNEYPERMISSION_TIME_SETSPEEDofficial2
TERRARIA_JOURNEYPERMISSION_WIND_SETFROZENofficial2
TERRARIA_JOURNEYPERMISSION_WIND_SETSTRENGTHofficial2
⁠Command-line

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

NameImageDefaultDescription
TERRARIA_ANNOUNCEMENTBOXRANGEofficialSets the "Announcement Box" text messaging range in pixels, -1 for serverwide announcements.
TERRARIA_CONFIGofficial/data/config.txtSets the configuration file path.
TERRARIA_DISABLEANNOUNCEMENTBOXofficialDisables the text announcements that "Announcement Box" makes when pulsed from wire.
TERRARIA_FORCEPRIORITYofficial

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_IPofficialSets the IP address for the server to listen on.
TERRARIA_LOBBYofficial

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

  • friends
  • private
TERRARIA_STEAMofficial0Toggles Steam support.
TSHOCK_ADDITIONALPLUGINStshock/data/plugins/Sets the additional plugins directory path.
TSHOCK_CONFIGPATHtshock/data/Sets the configurations directory path.
TSHOCK_CRASHDIRtshock/data/crashes/Sets the crashes directory path.
TSHOCK_LOGPATHtshock/data/logs/Sets the logs directory path.
TSHOCK_WORLDSELECTPATHtshock/data/worlds/Sets the worlds directory path.

⁠Supported architectures

ImageArchitecture(s)
officiallinux/amd64
tshocklinux/amd64

⁠Supported build arguments

NameImageDefaultDescription
TERRARIA_VERSIONofficial
tshock
1.4.4.9Sets Terraria⁠ version
TERRARIA_TSHOCK_VERSIONtshock5.2.0Sets 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⁠.

Tag summary

Content type

Image

Digest

sha256:ea7bef0b0…

Size

46.2 MB

Last updated

over 2 years ago

docker pull dstmodders/terraria-server