itzg / docker-minecraft-server

Docker image that provides a Minecraft Server that will automatically download selected version at startup
https://docker-minecraft-server.readthedocs.io/
Apache License 2.0
9.28k stars 1.53k forks source link

Unicode support in docker attach #2423

Open realwoopee opened 1 year ago

realwoopee commented 1 year ago

Describe the problem

When attached to the server console using docker attach multiple backspace key presses are required to delete non-ascii character.

Example:

  1. Enter тест into the console, then press backspace 8 times, then enter 'version' and press enter
  2. Do exactly the same thing, but press backspace only 4 times, not 8
  3. Enter say into the console, then enter тест and press backspace 4 times, then enter test and press enter image image

Note the misaligned 'vers' happening because of the cursor moving back 8 times. I am using Putty and Debian for the host, but everywhere else (including docker exec <container> bash) cyrillic characters are handled correctly.

Container definition

Paste run command or compose file here

tty and stdin_open are both set to true

Container logs

Paste logs here
itzg commented 1 year ago

Since you did not provide your container config I cannot confirm how you have TTY or stdin setup. In any case, docker attach is a docker leave mechanism that connects directly to the Minecraft server process. It is beyond the control of the image to further influence that.

itzg commented 1 year ago

...one thing you could try it setting the env variable EXEC_DIRECTLY to "true". The server may no longer stop gracefully, but that'll eliminate any possible interference in the console attachment.

realwoopee commented 12 months ago

EXEC_DIRECTLY: 'true' does fix the issue.

I mentioned tty and stdin in the original message, but here is the full container config:

version: "3"

services:
  server0:
    image: itzg/minecraft-server:latest
    ports:
      - 25565:25565
      - 25575:25575
    environment:
      EULA: "TRUE"
      TYPE: 'PAPER'
      ICON: <redacted>
      OVERRIDE_ICON: 'TRUE'
      VERSION: '1.20.1'
      DIFFICULTY: 'hard'
      USE_AIKAR_FLAGS: 'true'
      MEMORY: '6G'
      SNOOPER_ENABLED: 'false'
      SERVER_NAME: <redacted>
      RCON_PASSWORD: <redacted>
      MODRINTH_DOWNLOAD_OPTIONAL_DEPENDENCIES: 'false'
      MODRINTH_ALLOWED_VERSION_TYPE: 'beta'
      DATAPACKS: 'https://static.planetminecraft.com/files/resource_media/datapack/global-trades-e2450.zip'
      EXEC_DIRECTLY: 'true' # added this line as per your suggestion
    tty: true
    stdin_open: true
    volumes:
      - /home/fxserver/minecraft-server/server0/data:/data
      - /home/fxserver/minecraft-server/server0/plugins:/plugins
      - /home/fxserver/minecraft-server/server0/mods:/mods
      - /home/fxserver/minecraft-server/server0/config:/config
realwoopee commented 12 months ago

Reproduced with minimal setup:

version: "3"

services:
  server0:
    image: itzg/minecraft-server:latest
    environment:
      EULA: "TRUE"
      #EXEC_DIRECTLY: 'true'
    tty: true
    stdin_open: true

With EXEC_DIRECTLY: 'true' everything works fine, without the setting the issue is reproduced.

I believe this issue comes from the mc-server-runner proxying the java process's stdin/stdout.

I investigated the code, but due to my lack of Golang background, my further investigation yielded no results.

itzg commented 12 months ago

Thanks, yes, I realized later it was probably that. I'll need to research how to directly associate the stdin/out rather than relaying the content between them.