Dockerized Terraria dedicated server with automatic updates.
- Automatic Updates - Enumerates and installs latest Terraria server on startup, with hourly update checks
- Remote Commands - Execute server commands via
docker execeq.docker exec cmd playingto list online players - World Persistence - World data stored in local volume
# Clone repository
git clone https://github.com/coffeegrind123/terraria-server-docker-1.4.5.git
cd terraria-server-docker-1.4.5
# Start server
docker-compose up -d
# View logs
docker-compose logs -fEdit docker-compose.yml:
terraria:
environment:
- TERRARIA_MAXPLAYERS=8
- TERRARIA_AUTOCREATE=3 # 1=Small, 2=Medium, 3=Large
- TERRARIA_DIFFICULTY=0 # 0=Normal, 1=Expert, 2=Master, 3=Journey
- TERRARIA_PASSWORD= # Leave empty for no password
- TERRARIA_WORLDNAME=world # World name (creates or loads this world)
- AUTO_UPDATE_ENABLED=1 # Enable automatic updatesThe TERRARIA_WORLDNAME variable controls which world to load or create:
- New world name: Creates a new world with that name
- Existing world name: Loads the existing world
- World files are stored in
./world/{WORLDNAME}.wld
Example configurations:
# Creative world
- TERRARIA_WORLDNAME=creative
# Hardcore world
- TERRARIA_WORLDNAME=hardcore
# Custom world path
- TERRARIA_WORLD=/custom/path/myworld.wldExecute server commands from your host:
# Show online players
docker exec terraria-server cmd playing
# Save the world
docker exec terraria-server cmd save
# Show help
docker exec terraria-server cmd helpWhen enabled, the container:
- Checks for updates hourly by enumerating available versions
- Warns players 2 minutes in advance and also the final 30 seconds before restart
- Saves world and gracefully shuts down
- Downloads and installs update
- Restarts server with new version
Update announcements show version numbers: Update available: v1450 -> v1452
World files persist in ./world/ directory. Each world is named according to TERRARIA_WORLDNAME.
Backup world:
tar czf terraria-backup-$(date +%Y%m%d-%H%M).tar.gz ./worldRestore world:
docker-compose down
tar xzf terraria-backup-YYYYMMDD-HHMM.tar.gz
docker-compose up -dSwitch to different world:
# Edit docker-compose.yml
- TERRARIA_WORLDNAME=adventure
# Restart
docker-compose restartForce new world:
docker-compose down
rm ./world/world.wld
docker-compose up -dOR change TERRARIA_WORLDNAME:
- TERRARIA_WORLDNAME=namehere# Start
docker-compose up -d
# View logs
docker-compose logs -f terraria
# Stop
docker-compose down
# Restart
docker-compose restart
# Force a clean rebuild and restart
docker compose build --no-cache; docker compose up -dFor advanced configuration, mount a custom config file:
terraria:
volumes:
- ./config.json:/terraria/TerrariaServer/Linux/serverconfig.txt:roExample config.json:
{
"ServerPort": 7777,
"MaxPlayers": 8,
"WorldName": "world",
"Password": "",
"Motd": "Welcome to my Terraria Server!"
}To enable FRP tunneling for remote access behind NAT/firewalls:
cp -f extras/frp.docker-compose.yml docker-compose.yml
cp -f extras/Dockerfile.frp .See extras/README.md for detailed setup instructions.