jammsen / docker-palworld-dedicated-server

Docker container to easily provision and manage Palworld Dedicated Server
https://hub.docker.com/r/jammsen/palworld-dedicated-server
MIT License
911 stars 158 forks source link

feat(error): throw when not running as root #246

Closed StaleLoafOfBread closed 5 months ago

StaleLoafOfBread commented 7 months ago

Breaking up #240 into smaller PRs

Much simpler implementation of the intent of #240. This simply checks if the container is running as root and throws a user friendly error if its not. The purpose of this is that the container is designed to be ran as root and can throw errors which are not docker beginner friendly if ran not as root such as in #203. More details below.

This screenshot shows what happens when ran as not root and then that it still works when ran as root. It does throw an error because I did not set the env vars for the test but shows it gets past the if statement I added.

image

More details

The intent is to let the user know they need run the container as root as in the --user if using docker run. Note if using docker run then leaving the arg out completely will default to root.

If using docker compose as I would assume most are, ensure they didn't define user in their compose file.

If using portainer, ensuring the user setting in advanced container settings, does not have a non-root user in it.

If anyone has any suggestions as to how best to convey that in the error message, I won't be offended.

jammsen commented 6 months ago

Im so sorry i totally forgot about this PR, i had so much stuff to do and didnt realize this is still waiting. Im very sorry, its now* on my plate and todo again. @StaleLoafOfBread @Callum027

jammsen commented 5 months ago

image

;)