A Docker image to deploy a Terraria server on any architecture
390
I am saying this because:
docker buildx to work right, I'm literally using Docker manifestarm32v7 image anymoreYou can still use the images I publish, I just won't guarantee they're the most up-to-date
In order to easily build your own image, follow Building the image manually.
This is a Docker image made to deploy a Terraria server.
The reason I made my own Docker image for this is because I want to be able to run it on multiple architectures, like ARM, since I'm personally going to deploy this on my Raspberry Pi. This requires a different approach at the way the server is set up and ran, see the Terraria Wiki.
This solution provides you with the ability to, theoretically, run this on any architecture that the Debian Docker container supports, and on which mono is available.
All of the server data is stored, inside the container, in the folder /home/terraria.
docker-compose.ymlHere is a very complete docker-compose.yml file that downloads the image from my prebuilt images:
version: "3.8"
services:
terraria:
container_name: terraria
restart: unless-stopped
tty: true
image: andy3153/terraria:latest
ports:
- "7777:7777"
networks:
net:
ipv4_address: 172.100.1.100
volumes:
- data:/home/terraria
- /etc/localtime:/etc/localtime:ro
networks:
net:
ipam:
driver: default
config:
- subnet: "172.100.1.0/16"
volumes:
data:
If a new Terraria Server version has appeared, you have to modify line 17 in setup.sh.
What you need to do is to change that number to the correct version. The number represents the Terraria's version without the dots in between (ex: '1436' means version 1.4.3.6):
_terrariaver="1436"
So, for example, when 1.4.4 releases, all you have to do is modify that to:
_terrariaver="144"
An easy, copy-paste way of building and running the image is:
git clone https://github.com/Andy3153/terraria-docker
cd terraria-docker
# ... modify line 17 if new Terraria Server version dropped ... #
docker-compose up -d --build
docker runHere is a couple of short examples you could use to run your Docker container:
docker run -dt \
--name terraria \
-p 7777:7777 \
andy3153/terraria:latest
docker run -dt \
--name terraria \
-p 7777:7777 \
--mount source=terraria,destination=/home/terraria \
andy3153/terraria:latest
docker-compose.yml translated into a docker run command:# Creating the network
docker network create \
--driver=default \
--subnet= 172.100.0.0/16 \
terraria_net
# Creating the volume
docker volume create terraria_data
# Running the actual Docker container
docker run -dt \
--name terraria \
-p 7777:7777 \
--net terraria_net \
--ip 172.100.0.100 \
--mount source=terraria,destination=/home/terraria \
andy3153/terraria:latest
After running the container and pointing a volume at the /home/terraria folder, you'll see a couple of files and folders inside it. Here are the most important ones:
serverconfig.txtThis is the Terraria Server's configuration file. Here, you've got details about the used port, the world that will get loaded by default, the settings for autocreating a world etc. In short, this is the file you're going to be most interested in, most likely.
worlds/This folder is the home of all of your worlds. By default, it'll only have a single large world on normal mode, called world.
terrariactlThis is a shell script that makes it easier to manage the Terraria server.
Currently it has two options built-in, possibly more to come:
start -- You can use this to start the server automatically, in a Screen session, and it's the way the container is made to start the server upon bootconsole -- This attaches you to the Screen session the server is currently running into, allowing you to see the console. To do that, check out Usage.startServer.shThis contains the command that starts the server. If, for some reason (ex: debugging), you don't want to start the server inside of a Screen session, like with the terrariactl script, as mentioned above, you can use this directly.
Other files and folders belong to Terraria Server, you shouldn't (need) to touch those.
After the image has been deployed, by default, it is going to generate a large world on normal mode, named world. To make any changes, you have to go inside the volume you've created. Locally, on your Docker host, volumes are usually stored in the /var/lib/docker/volumes folder.
You can access the Terraria Server's console using a docker exec command:
docker exec -it yourcontainername su terraria -c "terrariactl console"
This is going to attach you to the Screen session that the Terraria server is ran inside. In order to close the server, run exit. To detach from the Screen session, use Ctrl+A+D.
I am fully open for contributions of any sort. I am, still, pretty much an intermediate user, regarding Docker, so, any help is going to be welcome.
Content type
Image
Digest
Size
86.4 MB
Last updated
over 4 years ago
docker pull andy3153/terraria