Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

¿How attach to server console? #8

Closed
Nitrosito opened this issue Sep 5, 2019 · 10 comments
Closed

¿How attach to server console? #8

Nitrosito opened this issue Sep 5, 2019 · 10 comments

Comments

@Nitrosito
Copy link

Hi

Is it possible to enter commands to the minecraft server by attaching to the container? How do we do it? If I attach to the container I don't see that I can enter commands.

I speak of commands for the minecraft server executable, not of commands to the container.
a greeting

@itzg
Copy link
Owner

itzg commented Sep 5, 2019

docker attach should work in some form; however, I haven't experimented to see what combination of parameters need to be set on the container initially. I'm guessing -i and -t are probably needed on the docker run (or the equivalent settings in compose).

With that said, the bedrock server doesn't natively support rcon, which is what gets leveraged in my Java edition image. I'm thinking of enhancing the process wrapper with rcon or rcon-like console support, so that commands can be sent more easily.

@itzg
Copy link
Owner

itzg commented Sep 5, 2019

...as a quick experiment, I started a container with

docker run --rm -it -e EULA=TRUE itzg/minecraft-bedrock-server

and was able to attach and send the "help" command using:

docker attach 3c1633c5e90b
DEBU[0076] Forwarding signal                             signal="window changed"
DEBU[0076] Forwarding signal                             signal="window changed"
help
§2--- Showing help page 1 of 18 (/help <page>) ---
/? [command: CommandName]
/? <page: int>
/alwaysday [true|false]
/changesetting allow-cheats <true|false>
/changesetting difficulty <value: Difficulty>
/changesetting difficulty <value: int>
/clear [player: target] [itemName: Item] [data: int] [maxCount: int]
§2Tip: Use the <tab> key while typing a command to auto-complete the command or its arguments
read escape sequence

I then used Ctrl-P and Ctrl-Q to detach and leave the container running.

Is that sufficient for your deployment?

@itzg itzg added the status/waiting on feedback Waiting on feedback from author of issue label Sep 5, 2019
@Nitrosito
Copy link
Author

Of course @itzg !
I modify my docker-compose to set similar entrypoint

Thanks and regards

@no-response no-response bot removed the status/waiting on feedback Waiting on feedback from author of issue label Sep 6, 2019
@itzg itzg closed this as completed Sep 6, 2019
@bingobob
Copy link

bingobob commented Sep 9, 2019

I was trying to do the same thing. i.e. attach to server console to monitor stuff and issue commands. Would be interested in any progress here. thanks. good work, thanks for this.

@cyclingwithelephants
Copy link

cyclingwithelephants commented Apr 3, 2020

To get into the shell of a running container you should execute

kubectl exec -it --namespace ${NAMESPACE} ${POD_ID} bash

this opens a bash terminal that you can use to navigate, in the present working directory of the container. YOU NEED the -it flags, the i stands for interactive (I forget what t stands for, but man kubectl is your friend) from this point you can use the excellent rcon-cli tool by the same author.

Iif you're using docker but not k8s then replace kubectl with docker and remove the namespace argument, the pod ID will instead be the UID of the container, I believe you can find this using docker ps (I may be forgetting some flags)

@Oliver84
Copy link

Of course @itzg !
I modify my docker-compose to set similar entrypoint

Thanks and regards

Can you share how you attached to this with docker-compose? I started the server with docker-compose but when I attached, it's not taking any of my input commands.

@itzg
Copy link
Owner

itzg commented Apr 17, 2020

@Oliver84 in your compose file you'll need these two items:

https://github.com/itzg/docker-minecraft-bedrock-server/blob/master/examples/docker-compose.yml#L14-L15

With that and restarting the container you'll then be able to use docker attach.

mingtsay added a commit to mingtsay/minecraft-docker-image that referenced this issue Jun 30, 2022
@dominic-ks
Copy link

dominic-ks commented Feb 2, 2024

Hey @itzg, sorry to comment on an old issue, but can I clarify that it's suggested here that I should be able to just use docker attach and then run commands for the Minecraft server directly in the terminal? I can attach no problem, and have tried with the stdin_open and tty options you pointed to in the example compose file, but I just get a regular bash terminal, running help just shows me Linux commands, and attempting to run any Minecraft commands it tells me they're not found. Have I missed something?

@itzg
Copy link
Owner

itzg commented Feb 2, 2024

I just get a regular bash terminal, running help just shows me Linux commands

In that case the docker attach didn't actually work or you're not doing something right. Make sure you're not doing an exec which will execute a new shell within the container.

@dominic-ks
Copy link

you're not doing something right

Yep, I assumed that using the VS Code Docker extension and clicking "attach" on it would run attach, which I guess it does not.

Cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants