itzg / docker-minecraft-bedrock-server

Containerized Minecraft Bedrock Dedicated Server with selectable version
MIT License
1.17k stars 220 forks source link

Provide mechanism similar to rcon-cli #15

Closed esticle closed 1 year ago

esticle commented 4 years ago

Noob question - Is it possible to have rcon-cli in the container like on the java edition?

itzg commented 4 years ago

Actually that's a great question...but unfortunately they haven't implemented rcon in the bedrock edition so including the cli wouldn't help.

Over here https://github.com/itzg/docker-minecraft-bedrock-server/issues/8#issuecomment-528544941 I show a work around where you can docker attach to the bedrock container and issue commands.

esticle commented 4 years ago

I guessed that was the case with rcon-cli thanks @itzg

Appreciate the pointer - just a quick one for yourself (or Nitrosito really) - what would the docker-compose equivalent look like? Not having much luck with:

...snip...
    ports:
      - 19132:19132/udp
    restart: unless-stopped
    command: run --rm -i  -e EULA=TRUE

Then,

# docker attach minecraft-bedrock
[2019-11-11 22:07:22 INFO] Server started.
/help
^P/help
help
^Ztime="2019-11-11T22:07:32Z" level=debug msg="Forwarding signal" signal=stopped
itzg commented 4 years ago

Here is a compose file that allows for using docker attach where it's the last two lines that are relevant:

version: '3.3'

services:
  bedrock:
    image: itzg/minecraft-bedrock-server
    environment: 
      EULA: "TRUE"
    ports:
      - 19132:19132/udp
    stdin_open: true
    tty: true

BTW, the command field is tempting, but it's typically for specifying the command arguments to run within the container.

esticle commented 4 years ago

@itzg That works perfectly, nice trick indeed, quite correct in my assumption about the command field - noted.

Tab-completion would be nice if it worked but this is way better than nothing at all, thanks!

jlucktay commented 4 years ago

There was a ticket logged in September 2018 on Mojang's bug-tracker Jira about the lack of RCON in BDS, but it was invalidated as it was a feature request, not a bug.

Feature requests should go to the suggestions subreddit.

I have made such a request here.

Off the back of the Reddit request, it has now been added to the feature parity list on the official wiki.

macchie commented 3 years ago

Check this out!

https://github.com/macchie/minecraft-bedrock-server-bridge

itzg commented 3 years ago

Awesome @macchie ! I can add that to the community solutions section if you're interested.

macchie commented 3 years ago

Awesome @macchie ! I can add that to the community solutions section if you're interested.

Of course! :) I'll make sure to make it better and more useful!

itzg commented 3 years ago

Added: https://github.com/itzg/docker-minecraft-bedrock-server/#community-solutions

macchie commented 3 years ago

Added: https://github.com/itzg/docker-minecraft-bedrock-server/#community-solutions

Thank you very much! I'm currently working on server commands feedback on Telgram and the HTTP API to execute commands.

SayaAEP commented 2 years ago

how download?

Bass-03 commented 2 years ago

Hello, I found a way to send commands to the server, when it was not started with the -it flags.

The docker image used is very simple so it lacks a few basic linux commands, lis ps. Anyway, this is what you have to do:

  1. get bash on the container with docker exec -it <bedrock id> /bin/bash
  2. send your command to the server process' STDIN echo "<your command>" > /proc/10/fd/0

That is it. The process that has the console running is /data/bedrock_server-1.19.11.01, you can find the correct id with find /proc -mindepth 2 -maxdepth 2 -name exe -exec ls -lh {} \; 2>/dev/null

Since we have the same image, I would guess we get the same PID for that process: 10

so you can just send commands like echo "gamerule showcoordinates true" > /proc/10/fd/0 echo "op myuser_please" > /proc/10/fd/0

Emilgoo commented 2 years ago

And you can be a little more clear? For the little ones in this topic. And how to do it on windows?

mattholy commented 2 years ago

Actually you can use the docker api to send commands into the Minecraft server. I believe it’s the best practice when you want to control your server by telegram

itzg commented 2 years ago

@mattholy can you clarify that? The previous suggestion made sense to me adapt into a script that can be exec'ed in the container.

mattholy commented 2 years ago

@mattholy can you clarify that? The previous suggestion made sense to me adapt into a script that can be exec'ed in the container.

please read this https://docs.docker.com/engine/api/v1.41/#tag/Container/operation/ContainerAttach if still a question, fell free to ask me

itzg commented 2 years ago

Now I understand. Doesn't need to be an API call though

https://github.com/itzg/docker-minecraft-bedrock-server#executing-server-commands

itzg commented 1 year ago

The suggestion from @Bass-03 has now been bundled into the image as send-command and documentation has been updated:

https://github.com/itzg/docker-minecraft-bedrock-server#executing-server-commands