jammsen / docker-sons-of-the-forest-dedicated-server

Docker container to easily provision and manage Sons of the Forest Dedicated Server with Wine
https://hub.docker.com/r/jammsen/sons-of-the-forest-dedicated-server
134 stars 19 forks source link

Permission issue #23

Closed Isoterik closed 11 months ago

Isoterik commented 11 months ago

Hello there! 1st of all, thanks for ur work.

i had a little permission issue setting things up.

as u stated under getting started:

Create 2 sub-directories on your Dockernode in your game-server-directory (/srv/sonsoftheforest/steamcmd and /srv/sonsoftheforest/game)

and then running: docker run --rm -i -t -p 8766:8766/udp -p 27016:27016/udp -p 9700:9700/udp -v $(pwd)/steamcmd:/steamcmd -v $(pwd)/game:/sonsoftheforest --name sons-of-the-forest-dedicated-server jammsen/sons-of-the-forest-dedicated-server:latest

it was unable to download the game into the /game folder. for /steamcmd it worked fine.

after that i deleted the /game folder and the /steamcmd folder. and then ran the bash command again. everything was now downloaded but i was unable to edit dedicatedserver.cfg and ownerswhitelist.txt due of a permission issue. then i checked the /game folder and /steamcmd folder permissions and it was both set as root:root (that did u might also encounter and then added the step to create the folders before running the docker command?).

so i changed the permissions for /game and /steamcmd sudo chown -R your_username:your_username game/ since i am not running things there as root user.

now everything works like charm!

may i provide a handy way to handle the server with screen?

start_sonsoftheforest.sh

#!/bin/bash

# Define the Docker run command
docker_command="docker run --rm -i -t -p 8766:8766/udp -p 28016:28016/udp -p 9700:9700/udp -v $(pwd)/steamcmd:/steamcmd -v $(pwd)/game:/sonsoftheforest --name sons-of-the-forest-dedicated-server jammsen/sons-of-the-forest-dedicated-server:latest"

# Start the Docker container in a detached screen window with the name "sonsoftheforest"
screen -dmS sonsoftheforest bash -c "$docker_command"

echo "Sons of the Forest dedicated server started in a detached screen window with the name 'sonsoftheforest'."

stop_sonsoftheforest.sh

#!/bin/bash

# Send the Ctrl+C command to the screen session named "sonsoftheforest"
screen -S sonsoftheforest -X stuff $'\003'

echo "Sent Ctrl+C command to stop the Sons of the Forest dedicated server."
jammsen commented 11 months ago

Hey @Isoterik happy to hear everything works now, Awesome!

Permissions

By default the Docker-Engine gets installed as root and the normal way Docker-Containers are run is also as root:root, it only differs if you use mechanics like users or user-remaps or UID/GID redirects. But thats not standard, while it is considered Best Practice. I did not include this in this Repo to keep things simple and make sure the setup i provide works everywhere.

May i provide a handy way to handle the server with screen?

The screen cmd you use looks nice and you might have a good use for it, but i personally host this via docker-compose mostly or "docker run -d ..." and use "docker logs -f ID" to watch logs. Thats simpler for me. Also i dont tend to use "-it" / "-i -t" in containers i host, i dont need them interactive, i somewhere learned its considered kinda Bad-Practice in "Container Hosting", therefore i did not include this in this Repo.

Isoterik commented 11 months ago

thanks for the reply @jammsen. i have only basic knowledge of docker. never read anything indepth. so i learned something again! you can consider this issue closed from my side :)

jammsen commented 11 months ago

Great! Thanks for your input and ideas and also thanks for sharing them! A good source to learn more about Docker is the Best-Practice pages: