Note: Still trying to navigate communities here on Lemmy to replace those from Reddit. If there is a better place such a question, I would welcome the suggestion.
I’m running a Synology NAS, which uses some flavor of Linux distribution. From there, among everything else running, I have a docker container hosting a Minecraft Bedrock Server. The MCBE server is great for fun, but not so great for resource usage. To handle this, most folks setup something to schedule the server to restart.
Within Synology, there is a task scheduler where I can run a user-defined script to restart the whole container:
docker restart mcbe-world
This works, but it’s a dirty reboot though. I worried about corrupting the world (which I do regularly backup). From within the Minecraft server terminal, the /stop
command will gracefully shut it down.
I can’t update the container with another application, like screen, because each MCBE update means replacing the entire container (and so destroying the changes). I am looking to somehow redirect a command to the server if possible.
Using docker exec -it mcbe-world
, I can execute what I want within the container.
The person here said, one can “inject commands by running the command as the appropriate account and redirecting it into the server” and they gave the example sudo su -s /bin/bash -c "echo say foobar > /run/service@name"
Unfortunately, this isn’t so clear and straight forward to me.
Would anyone here be able to articulate this more clearly for me or have an idea as to how I might issue that /stop command from the Synology scheduled script BEFORE restarting the container?
Thanks!
docker exec mcbe-world
just gives access to the container so commands can be executed./stop
is a specific command for the MC server running in that container. The process is already running and I am trying to figure out how to issue a command to it… and the other comment in this post referencing “rcon” might be a solution…yes, and that command I pasted will run that /stop command inside the docker container. The same way you can list files or do any other commands on a running container:
# docker exec heimdall ls -la / total 148 drwxr-xr-x 1 root root 4096 Jul 14 07:09 . drwxr-xr-x 1 root root 4096 Jul 14 07:09 .. -rwxr-xr-x 1 root root 0 Jul 14 07:09 .dockerenv drwxr-xr-x 1 abc abc 4096 Jul 14 07:09 app drwxr-xr-x 1 root root 4096 Jun 17 15:30 bin drwxr-xr-x 2 root root 12288 Jun 17 15:30 command drwxr-xr-x 7 abc abc 4096 Dec 3 2022 config drwxr-xr-x 1 abc abc 4096 Jun 23 20:35 defaults drwxr-xr-x 5 root root 340 Aug 19 04:52 dev -rwxr--r-- 1 root root 18257 Jan 1 1970 docker-mods drwxr-xr-x 1 root root 4096 Aug 19 04:52 etc drwxr-xr-x 2 root root 4096 Jun 23 20:35 heimdall