-
Notifications
You must be signed in to change notification settings - Fork 22
Home
You want to run your own SOTF server? Here you should find everything to get you started. English is not my native language. So, any feedback about wording is very welcome!
You need a Docker host which usually is a linux server of some kind. You can rent one, install one as a virtual machine (or WSL on Windows). Make sure it meets at least these specs:
- 10 GB RAM (8 sometimes is not enough)
- 4 Core CPU with at least 2 GHz
- 4 GB hard disk space
We recommend latest Ubuntu LTS version. The following tutorial is tested for this distribution. Managing docker installation and setup requires root permission. This is what sudo
does: Run a command with root permissions.
To get your operating system and all installed packages up to date, use this command:
apt update && apt -y full-upgrade && apt -y autoremove && reboot
Do this until it states that there are no more updates.
You need a text file editor. We recommend nano
. Install it like this:
sudo apt install nano
Find Docker official docs on their website.
- Check if Docker Engine is already installed. You can do this by running the following command in the terminal:
sudo docker version
It will output something like this:
root@TEST2:/home# sudo docker version
Client: Docker Engine - Community
Version: 26.1.3
API version: 1.45
Go version: go1.21.10
Git commit: b72abbb
Built: Thu May 16 08:33:29 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 26.1.3
API version: 1.45 (minimum version 1.24)
Go version: go1.21.10
Git commit: 8e96db1
Built: Thu May 16 08:33:29 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.32
GitCommit: 8b3b7ca2e5ce38e8f31a34f35b2b68ceb8470d89
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
- If you found it, check the version. If it is too old, remove it with this command (it may throw some errors because you do not have some of the packages):
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get remove $pkg; done
- Add Docker's repository (software shop) to your system:
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
- Install latest Docker version from their repo:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Check if everything works with this test container. It will download the latest image named "hello-world" from Docker hub (image shop for Docker containers), create a container from it and run it:
sudo docker run --rm hello-world
It will output something like this:
root@TEST2:/home# sudo docker run --rm hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:266b191e926f65542fa8daaec01a192c4d292bff79426f47300a046e1bc576fd
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
That's all for Docker and Docker Compose! You now can run any container from Docker Hub.
Docker will update itself when you run the system update commands from the A server
chapter from now on.
We now want to run the image of this GitHub repository in a Docker container. This is real easy as it is already baked and uploaded to Docker Hub. So just prepare some directories for dynamic data like game saves and server settings, grab and run it.
A Docker container is running a static operating system + the minimum of apps to get the SOTF server running. It cannot store any data. The whole container is always read-only.
Because of this you must define a space where the container can store data which persist after a container restart.
We recommend to create these as file system folders (compared to Docker volumes) for easy access to the files on it. More advanced Docker users of course can use volumes instead. I guess advanced Docker users do not even need this tutorial...
ℹ️ In the following replace your-user-name
with your real user name on the server.
When connecting to your ubuntu server you usually reside in your home directory which is at:
/home/your-user-name/
So, your prompt will look like this:
your-user-name@your-server:/home/your-user-name# 🔲
- Right here we recommend to create the folders needed for your Docker containers and ofc. the SOTF container:
# Create a folder for all Docker data
mkdir /home/your-user-name/docker
# Create a folder for the container which runs the SOTF server
mkdir /home/your-user-name/docker/sotf
# Create the subfolders needed for dynamic data of the container
mkdir /home/your-user-name/docker/sotf/sonsoftheforest
mkdir /home/your-user-name/docker/sotf/steamcmd
mkdir /home/your-user-name/docker/sotf/winedata
- Make the folders accessibe by all users and make executables inside executable:
sudo chmod -R 777 /home/your-user-name/docker/sotf
docker-compose is a small utility which takes a config file and builds a service mix from it. It makes defining a Docker setup a lot easier than running single commands to create evrything needed to run a/some container/s.
Since a compose file can include all services in one file (not only your SOTF service mix) we recommend to create this file one level above your SOTF container directories:
cd /home/your-user-name/docker
In there start editing the file docker-compose.yml
:
nano /home/your-user-name/docker/docker-compose.yml
Copy this and paste it to this file (also see this repo's example):
version: '3.9'
services:
sotf-server:
container_name: sotf-server
image: jammsen/sons-of-the-forest-dedicated-server
restart: always
environment:
ALWAYS_UPDATE_ON_START: 1
ports:
- 8766:8766/udp
- 27016:27016/udp
- 9700:9700/udp
volumes:
- /home/your-user-name/docker/sotf/sonsoftheforest:/sonsoftheforest
- /home/your-user-name/docker/sotf/steamcmd:/steamcmd
- /home/your-user-name/docker/sotf/winedata:/winedata
This will define one container with the name sotf-server
which is being built with the image jammsen/sons-of-the-forest-dedicated-server
. It will restart when crashed, update on start, use the given UDP ports and use the three folders which were created before. These folders are mounted into the file system of the container.
🔥 You also see that this container expects incoming connections on the UDP ports 8766, 27016 and 9700. Make sure your firewall (if any) is allowing this.
To install Docker on Windows, the easiest route would be to install Docker Desktop. Follow the instructions here to install. With this method, Docker Desktop will also need to be running in the background.
Also due to compatibility issues with mounting directories from an NTFS drive, you need to either mount directories within WSL (like above example, not from NTFS drives) or configure docker volumes in your compose file and mount them instead.
version: '3.9'
services:
sotf-server:
container_name: sotf-server
image: jammsen/sons-of-the-forest-dedicated-server
restart: unless-stopped
environment:
ALWAYS_UPDATE_ON_START: 1
ports:
- 8766:8766/udp
- 27016:27016/udp
- 9700:9700/udp
volumes:
- sotf-game:/sonsoftheforest
- sotf-steamcmd:/steamcmd
- sotf-winedata:/winedata
volumes:
sotf-game:
sotf-steamcmd:
sotf-winedata:
To access your files (e.g. save data) you can copy from/to the container. Make sure the container is stopped before doing any file transfers!
# copy container files to host
docker cp "$(docker ps -f name='sotf-server' --format '{{.ID}}'):/sonsoftheforest/userdata" path/on/host/machine/sotf-userdata
# copy host files to container
docker cp path/on/host/machine/sotf-userdata "$(docker ps -f name='sotf-server' --format '{{.ID}}'):/sonsoftheforest/userdata"
Now you are ready to start it for the first time. It will take a bit because is has to download/update some additional tools like Steam command line and Wine emulator. To see this in action just start the composition with active console output:
cd /home/your-user-name/docker
sudo docker-compose up
Wait until you see that the server is up and running. Then press Ctrl + C
to shut it down. Your folders are now filled with the files we will adapt in the next step.
Edit the settings of your server with this command: nano /home/your-user-name/docker/sotf/sonsoftheforest/userdata/dedicatedserver.cfg
It will look like this:
{
"IpAddress": "0.0.0.0",
"GamePort": 8766,
"QueryPort": 27016,
"BlobSyncPort": 9700,
"ServerName": "A SOTF server",
"MaxPlayers": 8,
"Password": "some-password-needed-to-join",
"SaveSlot": 1,
"SaveMode": "Continue",
"GameMode": "Normal",
"SaveInterval": 600,
"IdleDayCycleSpeed": 0.0,
"IdleTargetFramerate": 5,
"ActiveTargetFramerate": 60,
"LogFilesEnabled": false,
"TimestampLogFilenames": true,
"TimestampLogEntries": true,
"GameSettings": {
"Gameplay.TreeRegrowth": true,
"Structure.Damage": true
},
"CustomGameModeSettings": {
"GameSetting.Vail.EnemySpawn": true,
"GameSetting.Vail.EnemyHealth": "Normal",
"GameSetting.Vail.EnemyDamage": "Normal",
"GameSetting.Vail.EnemyArmour": "Normal",
"GameSetting.Vail.EnemyAggression": "Normal",
"GameSetting.Vail.AnimalSpawnRate": "Normal",
"GameSetting.Environment.StartingSeason": "Summer",
"GameSetting.Environment.SeasonLength": "Default",
"Structure.Damage": "true",
"GameSetting.Environment.DayLength": "Default",
"GameSetting.Environment.PrecipitationFrequency": "Default",
"GameSetting.Survival.ConsumableEffects": "Normal",
"GameSetting.Survival.PlayerStatsDamage": "Off",
"GameSetting.Survival.ColdPenalties": "Off",
"GameSetting.Survival.ReducedFoodInContainers": false,
"GameSetting.Survival.SingleUseContainers": false
},
"LanOnly": false,
"SkipNetworkAccessibilityTest": false
}
Change the server's name and password at least.
You can change the last two if you are facing some restricted network environment. If LanOnly
is set you must connect to your server by entering it's public ip in the game client.
You also may be interested in this config file:
nano /home/your-user-name/docker/sotf/sonsoftheforest/userdata/SonsGameSettings.cfg
In here you can change tree growth ratio and if structures can be destroyed.
By default a user is not allowed to do changes to docker nor control service status. If you want to make your user able to start/stop and debug the composition your user must become part of the group docker
:
sudo usermod -aG docker your-user-name
When you finished all the steps before you have your production ready SOTF server. Congratulations!
If your user is member of the group docker
you do not need sudo
in front of the commands.
# All these commands must be executed in the directory which holds the docker-compose.yml file
cd /home/your-user-name/docker
# Start the server and let it run in the background (detach)
sudo docker-compose up -d
# Stop the server (deletes the container also, but image and data of it persist)
sudo docker-compose down
# Get last 30 log lines of each running container and get all log lines while it is running
docker-compose logs --tail 30 --follow
# Get last 30 filtered log lines generated from game server (excluding debug logs)
watch "docker-compose logs | grep '#DSL' | tail -n 30"
Some more useful flags for docker-compose logs
:
-
-t
shows timestamps -
--no-log-prefix
hides the container name