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.55k stars 1.55k forks source link

Multiarch Server ENABLE_AUTOPAUSE broken #699

Closed ErstBlack closed 2 years ago

ErstBlack commented 3 years ago

While running a custom image based on itzg/minecraft-server:multiarch (the custom image only installs sudo and psmisc) on a Raspberry Pi 4, the Autopause functionality fails, causing the container to fail as well. This is being run as a docker stack, but I haven't seen the same issue when running the base image on an x86_64 machine.

These are the logs from the container:

2020-12-25T05:42:52.153501161Z [init] Running as uid=1000 gid=1000 with /data as 'drwxrwxr-x 6 1000 1000 4096 Dec 25 00:35 /data' 2020-12-25T05:42:52.404537252Z [init] Resolved version given LATEST into 1.16.4 2020-12-25T05:42:52.411584035Z [init] Autopause functionality enabled 2020-12-25T05:42:52.441925087Z [init] Warning: MAX_TICK_TIME is non-default, for autopause to work properly, this check should be disabled (-1 for versions >= 1.8.1) 2020-12-25T05:42:52.444114690Z [init] Resolving type given VANILLA 2020-12-25T05:42:52.462303373Z sudo: no tty present and no askpass program specified 2020-12-25T05:42:52.481962316Z [init] Setting server-name to 'Minecraft Server' in /data/server.properties 2020-12-25T05:42:52.744293527Z [init] Skip setting server-ip 2020-12-25T05:42:52.744533709Z [init] Setting server-port to '25565' in /data/server.properties 2020-12-25T05:42:52.753180732Z [init] Setting motd to 'A Vanilla Minecraft Server powered by Docker' in /data/server.properties 2020-12-25T05:42:52.765704430Z [init] Skip setting allow-nether 2020-12-25T05:42:52.765806188Z [init] Skip setting announce-player-achievements 2020-12-25T05:42:52.765829077Z [init] Skip setting enable-command-block 2020-12-25T05:42:52.765848706Z [init] Skip setting spawn-animals 2020-12-25T05:42:52.765869261Z [init] Skip setting spawn-monsters 2020-12-25T05:42:52.765888057Z [init] Skip setting spawn-npcs 2020-12-25T05:42:52.765906298Z [init] Skip setting spawn-protection 2020-12-25T05:42:52.765925168Z [init] Skip setting generate-structures 2020-12-25T05:42:52.765944075Z [init] Skip setting view-distance 2020-12-25T05:42:52.765963130Z [init] Skip setting hardcore 2020-12-25T05:42:52.765984686Z [init] Skip setting snooper-enabled 2020-12-25T05:42:52.766006260Z [init] Skip setting max-build-height 2020-12-25T05:42:52.766025648Z [init] Skip setting force-gamemode 2020-12-25T05:42:52.766046259Z [init] Setting max-tick-time to '-1' in /data/server.properties 2020-12-25T05:42:52.773244300Z [init] Skip setting enable-query 2020-12-25T05:42:52.773321281Z [init] Skip setting query.port 2020-12-25T05:42:52.773343484Z [init] Setting enable-rcon to 'true' in /data/server.properties 2020-12-25T05:42:52.781600271Z [init] Setting rcon.password to 'minecraft' in /data/server.properties 2020-12-25T05:42:52.789866614Z [init] Setting rcon.port to '25575' in /data/server.properties 2020-12-25T05:42:52.803492538Z [init] Skip setting max-players 2020-12-25T05:42:52.803601241Z [init] Skip setting max-world-size 2020-12-25T05:42:52.803624203Z [init] Setting level-name to 'world' in /data/server.properties 2020-12-25T05:42:52.812778239Z [init] Skip setting level-seed 2020-12-25T05:42:52.812871552Z [init] Setting pvp to 'true' in /data/server.properties 2020-12-25T05:42:52.819989335Z [init] Skip setting generator-settings 2020-12-25T05:42:52.820181073Z [init] Setting online-mode to 'true' in /data/server.properties 2020-12-25T05:42:52.841382423Z [init] Skip setting allow-flight 2020-12-25T05:42:52.841589384Z [init] Setting level-type to 'DEFAULT' in /data/server.properties 2020-12-25T05:42:52.867307530Z [init] Skip setting resource-pack 2020-12-25T05:42:52.867598193Z [init] Skip setting resource-pack-sha1 2020-12-25T05:42:52.867859245Z [init] Skip setting player-idle-timeout 2020-12-25T05:42:52.867982558Z [init] Skip setting broadcast-console-to-ops 2020-12-25T05:42:52.868097316Z [init] Skip setting broadcast-rcon-to-ops 2020-12-25T05:42:52.868188519Z [init] Skip setting enable-jmx-monitoring 2020-12-25T05:42:52.868289499Z [init] Skip setting sync-chunk-writes 2020-12-25T05:42:52.868417812Z [init] Skip setting enable-status 2020-12-25T05:42:52.869504151Z [init] Skip setting entity-broadcast-range-percentage 2020-12-25T05:42:52.869569020Z [init] Skip setting function-permission-level 2020-12-25T05:42:52.870445713Z [init] Skip setting network-compression-threshold 2020-12-25T05:42:52.870520120Z [init] Skip setting op-permission-level 2020-12-25T05:42:52.870561397Z [init] Skip setting prevent-proxy-connections 2020-12-25T05:42:52.870602193Z [init] Skip setting use-native-transport 2020-12-25T05:42:52.870638729Z [init] Skip setting enforce-whitelist 2020-12-25T05:42:52.873757135Z [init] Setting difficulty to 'normal' in /data/server.properties 2020-12-25T05:42:52.921447492Z [init] Setting/adding ops 2020-12-25T05:42:52.941428042Z [init] log4j2.xml already created, skipping 2020-12-25T05:42:52.941506430Z [init] Checking for JSON files. 2020-12-25T05:42:52.981548455Z [init] Copying any mods over... 2020-12-25T05:42:53.027028691Z [init] Copying any configs from /config to /data/config 2020-12-25T05:42:53.046572839Z [init] Setting initial memory to 2G and max to 2G 2020-12-25T05:42:53.051706516Z [init] Using Aikar's flags 2020-12-25T05:42:53.053486772Z [init] Starting the Minecraft server... 2020-12-25T05:42:53.073300528Z OpenJDK Client VM warning: G1 GC is disabled in this release. 2020-12-25T05:42:53.159659982Z [Autopause loop] Failed to start knockd daemon. 2020-12-25T05:42:53.159742999Z [Autopause loop] Possible cause: docker's host network mode. 2020-12-25T05:42:53.159767240Z [Autopause loop] Recreate without host mode or disable autopause functionality. 2020-12-25T05:42:53.159788591Z [Autopause loop] Stopping server. 2020-12-25T05:42:53.170306962Z 2020-12-25T00:42:53.169-0500 WARN mc-server-runner sub-process failed {"exitCode": -1} 2020-12-25T05:42:53.170384535Z 2020-12-25T00:42:53.170-0500 INFO mc-server-runner Done

I'm using the following entries for my compose file: version: '3.8' services: minecraft-server: image: itzg/minecraft-server:multiarch environment: EULA: "TRUE" ENABLE_AUTOPAUSE: "TRUE" AUTOPAUSE_TIMEOUT_EST: "1200" OVERRIDE_SERVER_PROPERTIES: "TRUE" MAX_TICK_TIME: "-1" DIFFICULTY: "normal" SERVER_NAME: "Minecraft Server" USE_AIKAR_FLAGS: "true" DISABLE_HEALTHCHECK: "true" MEMORY: "2G" GUI: "FALSE" ports:

Is Autopause functionality currently supported on the multiarch version of the image?

itzg commented 3 years ago

@Oekn5w, any suggestions for @ErstBlack to debug this further? I'm not sure if others have attempted auto-pause on RaspberryPi / arm32v7, so perhaps there's latent issue in that build of knockd?

Oekn5w commented 3 years ago

@itzg looking at the multiarch Dockerfile, I'm wondering why sudo is not getting installed in the image, is it included in the base image? Pulling the amd64 multiarch image and running it fails because it's missing sudo.

Unfortunately I currently don't have a spare RPi nor a RPi4 at all. I'll try setting up a VM.

@ErstBlack if you want to help toubleshooting, could you please recreate the container with autopause disabled and bash into it (docker exec -it <name> /bin/bash) to run:

knockd --version
knockd -c /autopause/knockd-config.cfg -D
ifconfig

notes: The second knockd runs the utility in debug mode (-D), as opposed to daemon mode (-d) in the autopause files. This should print an error message. For ifconfig to work, you need to install net-tools. ifconfig shouldn't expose private information, please check. I'm mostly interested in the available interfaces.

Is the RPi4 using the arm32v7 or the arm64 image?

ErstBlack commented 3 years ago

arm32v7, and can do, I'll check it out later today.

itzg commented 3 years ago

@itzg looking at the multiarch Dockerfile, I'm wondering why sudo is not getting installed in the image, is it included in the base image? Pulling the amd64 multiarch image and running it fails because it's missing sudo.

It's because I wanted to avoid some signal forwarding quirks of sudo and use gosu here instead; however, there's no harm in also installing sudo, so I can add that.

itzg commented 3 years ago

@Oekn5w sudo is now included in the latest image for multiarch and multiarch-latest.

ErstBlack commented 3 years ago

@itzg Just a heads up, I also had to install psmisc because killall wasn't installed either, which I believe is used in a handful of places for the autostart functionality

ErstBlack commented 3 years ago

@Oekn5w

root@50bc2fe12ac8:/data# knockd --version knockd 0.7

root@50bc2fe12ac8:/data# knockd -c /autopause/knockd-config.cfg -D
config: new section: 'options'
config: log file: /dev/null
config: new section: 'unpauseMCServer-server'
config: unpauseMCServer-server: sequence: 25565:tcp
config: unpauseMCServer-server: seq_timeout: 1
config: unpauseMCServer-server: start_command: /sbin/su-exec minecraft:minecraft /autopause/resume.sh
config: tcp flag: SYN
config: new section: 'unpauseMCServer-rcon'
config: unpauseMCServer-rcon: sequence: 25575:tcp
config: unpauseMCServer-rcon: seq_timeout: 1
config: unpauseMCServer-rcon: start_command: /sbin/su-exec minecraft:minecraft /autopause/resume.sh
config: tcp flag: SYN
ethernet interface detected
Local IP: 10.0.0.39
Adding pcap expression for door 'unpauseMCServer-server': (dst host 10.0.0.39 and (((tcp dst port 25565) and tcp[tcpflags] & tcp-syn != 0)))
Adding pcap expression for door 'unpauseMCServer-rcon': (dst host 10.0.0.39 and (((tcp dst port 25575) and tcp[tcpflags] & tcp-syn != 0)))
^C
root@50bc2fe12ac8:/data# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 10.0.0.39  netmask 255.255.255.0  broadcast 10.0.0.255
        ether 02:42:0a:00:00:27  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1  bytes 376 (376.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1450
        inet 10.0.3.3  netmask 255.255.255.0  broadcast 10.0.3.255
        ether 02:42:0a:00:03:03  txqueuelen 0  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1  bytes 376 (376.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.18.0.8  netmask 255.255.0.0  broadcast 172.18.255.255
        ether 02:42:ac:12:00:08  txqueuelen 0  (Ethernet)
        RX packets 471  bytes 340207 (340.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 312  bytes 22647 (22.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 8  bytes 1083 (1.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8  bytes 1083 (1.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Oekn5w commented 3 years ago

@itzg beside the psmisc package also net-tools have to be installed (netstat command). However, something else seems broken in the multiarch image. I cannot get the original functionality to work even with these tools installed. I'll look into it in the next days.

@ErstBlack huh, I see no error in starting the knockd command. Did you initially build a new image with sudo and psmisc or did you install them by bashing into the container? Is it possible that the original issue failed because it denied the sudo request from user minecraft rather than the knockd command? BTW: Do you know why you have 3 ethernet interfaces in the ifconfig? Both in my VM and the deployed servers (NUC) I only have one ethernet interface in the containers.

ErstBlack commented 3 years ago

@Oekn5w For the original issue, I built a new image which effectively just ran apt update && apt install -y psmisc sudo. For this test, I just bashed into the base image after it came up and installed psmisc and net-tools, as I grabbed the updated multiarch image that @itzg put out so it already had sudo.

I imagine it's the networks associated with docker swarm. i.e. ingress because of the published port, gwbridge because it's running in a swarm, and one specifically for the minecraft stack.

ErstBlack commented 3 years ago

@itzg @Oekn5w So, playing around with it, I think I might have figured out a few issues. After making a new image with psmisc and net-tools installed, the knockd service worked properly and tried to run after the timeout, i.e. 600 seconds.

At that point, however, the java process did not stop. It looks like the issue has to do with the ps -a command in pause.sh. Changing the ps -a to ps -ax allowed the if statement to return properly.

After that though, the killall returned java: no process found. The specific reason why I'm not sure about in particular. Could be that it doesn't have a tty, could be because it's running as the minecraft user, etc.

Changing the killall to a pkill, however, seems to have resolved the issue. If you make that change, you won't need to install psmisc as pkill is from the procps package, which is already installed.

Oekn5w commented 3 years ago

Cool, thanks for troubleshooting. I think a bit more robust writing of the functionality is in order. Seeing as you have several non-loopback interfaces, a knockd daemon should probably be started for each of those. I assume something similar prevents autopause from working in portainer environments.

itzg commented 3 years ago

Thanks for the help both of you. A PR will be great for the additional packages and tweaks.

ErstBlack commented 3 years ago

708

github-actions[bot] commented 2 years ago

This issue is stale because it has been open 30 days with no activity. Please add a comment describing the reason to keep this issue open.