ryshe/terraria[UPDATE] I know a lot of people are excited for Terraria v1.4 Journey's End! This source code is built around the pre-release of TShock. Will continue to update as new releases come out.
[UPDATE 2] Added a mobile-1.4.0.5 tag to for those that want a dedicated mobile server. It runs similar to the vanilla-* version, however the cli prompts were not listing the options. Following the instructions here helped me work through the prompts and a world was generated. This version is largely untested though since I do not have the mobile version of the game. PRs are always welcome!
This project is a Dockerfile to containerize TShock and Terraria TerrariaServer.exe to run on linux. Docker will remove the need for someone to worry about how to setup a server in linux with all the right dependencies to run. The installation and usage instructions are written with complete beginners in mind.
First you need a linux machine with Docker installed. Everything from here on out assumes the docker service is running (you may need to start the service after install).
Next create a directory for your world file, configuration, and logs
bashmkdir -p $HOME/terraria/world
For the first run you will need to generate a new world with a size where: 1=Small, 2=Medium, 3=Large
bashsudo docker run -it -p 7777:7777 --rm -v $HOME/terraria/world:/root/.local/share/Terraria/Worlds ryshe/terraria:latest -world /root/.local/share/Terraria/Worlds/<world_name_here>.wld -autocreate <world_size_number_here>
Note: If you close the the terminal, the server will stop running. You will need to restart with a preexisting world. It may
be worth while to close after creation anyway to update the initial config.json settings.
To create a world with a few more initial options, you can do so in an interactive mode.
bashsudo docker run -it -p 7777:7777 --rm -v $HOME/terraria/world:/root/.local/share/Terraria/Worlds ryshe/terraria:latest
bashsudo docker run -d --rm -p 7777:7777 -v $HOME/terraria/world:/root/.local/share/Terraria/Worlds --name="terraria" -e WORLD_FILENAME=<.wld world_filename_here> ryshe/terraria:latest
Note: This command is designed to run in the background, and it is safe to close the terminal window.
Any config.json in the directory will automatically be loaded. The <world_file_name>.wld should be the name of your wld file in your $HOME/terraria/world directory.
Updating is easy!
Grab the latest terraria container
bashdocker pull ryshe/terraria:latest
First we need to find our running container to stop, so we can later restart with the latest
bashdocker container ls | grep ryshe/terraria
The first few numbers and letters, on a line, are the container hash. Remember the first 3 or so letters or numbers
Example:
bashf25261ac55a4 ryshe/terraria:latest "/bin/sh bootstrap.s…" 3 minutes ago Up 3 minutes 0.0.0.0:7777->7777/tcp, 7878/tcp reverent_solomon
f25 would be the first few letters/numbers of the container hash
NOTE: If you see multiple lines, find the one that still has an up status.
Stop and remove the container
bashdocker container rm -f xxx # xxx is the letters/numbers from the last step
Start your container again with your world (see the Quick start)
Provision a linux machine that can support docker and containerization. For more information visit docker. For a small or medium world with no more than 8 users a linux machine with 1-1.5GB of ram should suffice. If you are running a vm in the cloud, make sure to expose tcp port 7777 and udp port 7777.
Before starting the build process make sure the latest tshock version is specified in the Dockerfile under
DockerfileADD [***] /
Assuming git and docker are installed..
Clone this repository
bashgit clone [***]
Open a terminal window into the directory downloaded by the git
Build the container
bashdocker build -t <name_here> .
Whether you build your own container, or use my container published to docker hub, we are ready to run our terraria server!
Note: For a full set of docker run options go here
The first run of the server will give you the opportunity to create a world, and it will generate the server's config file. You may wish to add the config file for many reasons, but one of which is to add a password to your server.
bashdocker run -it --rm -p 7777:7777 -v $HOME/terraria/world:/root/.local/share/Terraria/Worlds ryshe/terraria:latest
Let's break down this command:
| Command Part | Description |
|---|---|
docker run | tells linux to run a docker image |
-it | run interactively and output the text to terminal |
--rm | remove docker container when the container stops or fails |
-p 7777:7777 | exposes terraria port <host machine side>:<container side> |
-v $HOME/terraria/world:/root/.local/share/Terraria/Worlds | maps a folder on the host machine into the container for saving the .wld file. This does not have to be $HOME/terraria/world. Anything left of the : is host machine directory |
ryshe/terraria | the name of the image. This could be your image if you build from source |
:latest | the tag, which defaults to latest if not specified. latest is the most recently published container |
-v volume.After a world has been generated, you may want to load directly into it.
bashdocker run -d --rm -p 7777:7777 -v $HOME/terraria/world:/root/.local/share/Terraria/Worlds ryshe/terraria:latest -world /root/.local/share/Terraria/Worlds/<world_filename_here>.wld
Let's break down the command:
| Command Part | Description |
|---|---|
-d | run this in the background. It is okay to close the terminal window, the container will continue to run |
-world /root/.local/share/Terraria/Worlds/<world_filename_here>.wld | specifies the world file name you wish to immediately load into |
ryshe/terraria:latest portion of the lineA volume exists to support plugins. Create a folder, not inside your /world folder, for your plugins
bashmkdir ServerPlugins
Mount the plugins directory with an additional -v switch on your docker run ... command
bash-v <path_to_your_ServerPlugins_folder>:/plugins
A separate directory can be volumed in for storing logs outside of the image
bash-v <path_to_store_logs>:/tshock/logs
sudo may be required to run docker commands.
Please post to the TShock team with questions on how to run a server.
Any additional command-line instructions can be added to the end of either method for launching a server. Docker maps the $HOME/terraria/world linux-host folder to the /tshock/world container-folder.
Expecting your server to run for a while? Add --log-opt max-size=200k to limit your log file size. Otherwise one day you will wake up to see all your hdd space chewed up for a terraria docker setup!
Email me rsheehan at gmail dot com if any of these instructions do not seem to work.
git checkout -b my-new-featuregit commit -am 'Add some feature'git push origin my-new-feature探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务