TheRemote / Legendary-Java-Minecraft-Geyser-Floodgate

Legendary Java Minecraft + Geyser + Floodgate + Paper Dedicated Server for Docker allowing Bedrock players to connect to a Java server
https://jamesachambers.com/minecraft-java-bedrock-server-together-geyser-floodgate/
MIT License
157 stars 34 forks source link

Docker not working as Azure container instance #1

Closed Sam7 closed 2 years ago

Sam7 commented 2 years ago

Thanks heaps for putting this together! I'm trying to host this in an Azure container, but it keeps showing up as Terminated right away.

Here is a terraform file, that should help replicate the issue: https://gist.github.com/Sam7/7256688e8c6c5881b23bd535e04d1bfb

I'd appreciate help :) My kids are super keen on playing ogether between Java and Bedrock!!

TheRemote commented 2 years ago

Hey Sam7,

Welcome! Do you have any record of the container startup output by chance? I do not have Azure or any of that and have never used it before. If it's free I would definitely try it.

Is there any output in the "logs" folder? I would imagine not because it doesn't sound like it's getting very far.

It looks like this should get us what we need: https://docs.microsoft.com/en-us/azure/container-instances/container-instances-get-logs

We need to see the general output / startup log to see what is going wrong here and we should be able to figure it out! My understanding is that it looks like that should give us those logs (or at least some logs to look at here to start with).

Sam7 commented 2 years ago

Thanks TheRemote, I looked before but it's not super informative. It's just showing Must be connected to a terminal.. The -it option is not available in Azure so I wonder whether that's the issue!?

Here is more: Paper Minecraft Java Server Docker + Geyser/Floodgate script by James A. Chambers Latest version always at https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate Don't forget to set up port forwarding on your router! The default port is 25565 and the Bedrock port is 19132 Port used: 25565 Bedrock port used: 19132 Updating to most recent paperclip version ... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 159 100 159 0 0 1404 0 --:--:-- --:--:-- --:--:-- 1407 Latest paperclip build found: 132 % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 36.3M 100 36.3M 0 0 94.8M 0 --:--:-- --:--:-- --:--:-- 94.8M % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11520 100 11520 0 0 9814 0 0:00:01 0:00:01 --:--:-- 9820 Floodgate is up to date % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 11502 100 11502 0 0 9871 0 0:00:01 0:00:01 --:--:-- 9881 Updating Geyser... % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 12.9M 100 12.9M 0 0 2618k 0 0:00:05 0:00:05 --:--:-- 2776k Starting Minecraft server... Must be connected to a terminal.

Full log: console logs.txt

Thanks for any hints.

TheRemote commented 2 years ago

Hey Sam7,

Great, that is definitely exactly what we needed! So you are definitely right about what is happening. The docker -it option launches it with an interactive terminal. There is a way to do this with docker-compose as well: https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate/blob/main/docker-compose.yml

It looks like you can do all this with Azure too. It honestly looks different than your configuration here to be perfectly honest but not that different. You are also using a template file. You can actually use docker-compose though like this (within Azure): https://docs.docker.com/cloud/aci-integration/

It looks like there's even a handy one liner install script to install Docker compose. I don't know how else you can do this but I won't say there isn't some other way (using some command or switch in the Azure launch line or configuration). There might be. When I started searching though for the best way to do this it led me straight to docker-compose within Azure.

The documentation says using these features (ACI) you can use all of the normal Docker commands. Given that we have no idea what the equivalent variables are for Microsoft or if there even are any (I found a lot of different weird and dirty methods to do this that were 10x more complicated than what I'm suggesting) I would strongly suggest going this route so you can use the real / native Docker features and you will not encounter these issues.

It looks like you will end up with a docker-compose.yml file that looks pretty similar to the one you sent me. It just seems to be using a different part of the Microsoft Azure / Docker stack (and one that looks like they have a one-liner script to help you install it).

It should work exactly how you want with the Docker compose integration. The Docker compose version works exactly like this. It just uses the docker-compose .yml file instead of the Microsoft one. Microsoft does support this fortunately!

This problem used to happen with docker-compose before that file existed. The docker-compose.yml solves the terminal issue (and it's the only way to solve it without actually launching with docker -it that I know of). Since this is supported in Azure I'm almost certain this will work for you (especially after checking that Microsoft documentation I linked to). Specifically the installation section for Docker-compose is here (you can use the one liner or just download it from the Releases section it says): https://docs.docker.com/cloud/aci-integration/#install-the-docker-compose-cli-on-linux

Would you be willing to give that a try? It looks pretty straightforward and should end up being a pretty nice clean setup with simple configuration files and Docker services, etc.

Sam7 commented 2 years ago

Looks like the the stdin_open and tty are not supported in ACI: https://docs.docker.com/cloud/aci-compose-features/ 😔

Is there a way to run it not requiring interactive mode?

TheRemote commented 2 years ago

I see nothing in there that says that. I don't Ctrl+F find anything related to stdin_open or tty at all. I do see plenty of examples of people using these features:

https://www.linkedin.com/pulse/story-born-cloud-windows-containers-kubernetesand-ivaylo-barakov/ https://stackoverflow.com/questions/65048750/cant-deploy-docker-compose-infrastructure-to-azure-container-instances https://zimmergren.net/netcore-azure-docker-swarm-cloud/

If this feature doesn't work it means Docker actually doesn't work in Azure. Not really. It wouldn't be able to run background console applications which is a bit of a dealbreaker considering that is a lot of applications to shut out of your platform as many Enterprise applications work exclusively this way. This is not the case fortunately. Minecraft is literally their own product so they even design their applications this way.

The options might sound weird but the option we are talking about is literally to run a console application in the background. Yes, this is absolutely required for the Minecraft server (by Microsoft's own design) as it is a console application that requires a tty. I'd imagine the reason this isn't listed on the list you linked above is that this is core Docker functionality. It's not Docker if this doesn't work basically.

The only issue you are having is passing that option to the command line when invoking the container through Azure. There is nothing special I will have to change in the container for this to work. We just have to figure out how to launch it with those options. After doing further research I'm positive this is supported but I assumed it was because if it's not then nobody would want to use this platform for anything related to Docker since it can't run background console applications which lots of people/companies have.

Did you try it? What errors did you get? I'm pretty sure I used that 12 month free Azure trial at some point but if I tried this I would just make sure the docker-compose components are present, set up my docker-compose.yml file with the name of the volume and then run it. Provided the ports are opened in the firewall/network configuration that should be all there is to it.

Sam7 commented 2 years ago

I think you might be right to assume that interactive and tty are just activated by default.

Yes I've tried it with this docker compose file, which needs to look slightly differently, but it works: https://gist.github.com/Sam7/a4f13b19affb9775eb253950cb32f6f0

It deploys fine, but I get exactly the same issues as mentioned above. Then it keeps restarting or showing up as Terminated (depending on the restart policy)

FYI: I can run marctv/minecraft-papermc-server:latest fine, without issues. 🤔

Sam7 commented 2 years ago

Looks like someone from MS has an idea here: https://docs.microsoft.com/en-us/answers/questions/976453/unable-to-run-aci-container-with-tty-and-stdin-ope.html?childToView=977274#answer-977274

"Inside the docker container, run script /dev/null first. Then you should be able to start screen"

This is where I reach the boundaries of my docker knowledge. How would I do that?

TheRemote commented 2 years ago

We would need to look at the startup logs again for sure. There's 1000 things it could be and there's no reason to just start guessing. It should tell us what the problem is. It's probably going to be some kind of permissions error. My guess would be something to do with the Azure volume needing a checkbox pressed somewhere or something like that.

The Docker container is always the same on every machine. This is basically pure environment / configuration. Let's take a look at the logs here for the container and see what Azure still doesn't like! If it's something that requires a container change I would make it but let's just wait and see here because the whole point of Docker is the same container runs everywhere so I'd imagine it's going to be something else here.

I could definitely add an Azure template to the library as well once we tackle this as you're the first person I think really trying it on Azure specifically! That's basically how we came up with the docker-compose.yml template originally (it was just for a different version of the container). For that to be created though it took another thread with 20-30 replies just like this while we figured it out the first time if that makes sense.

I really think with the template available it will be pretty easy but since you're the first one trying it yeah it's definitely a rough time for sure! If that were the case it would have been simple as running the template we're working on figuring out so I do intend to for sure make changes/improvements so that not everyone trying it on Azure has this experience (yikes). The goal is to get it there which it is there for most platforms (this is just a new one for it).

Sam7 commented 2 years ago

FYI Here is trouble shooting guide with a section on "Container continually exits and restarts", which is exactly what I'm seeing: https://docs.microsoft.com/en-us/azure/container-instances/container-instances-troubleshooting#container-continually-exits-and-restarts-no-long-running-process

TheRemote commented 2 years ago

I just need to see the same thing you showed me last time. The startup logs. I have no idea what any of that is. I don't have access to your Azure instance so I cannot pull up the logs for it. They aren't going to be the same as last time unless the tty and stdin aren't actually fixed. These errors tell me what is wrong with the container basically.

https://docs.microsoft.com/en-us/azure/container-instances/container-instances-get-logs

Sam7 commented 2 years ago

Of course. Logs are exactly the same:

Paper Minecraft Java Server Docker + Geyser/Floodgate script by James A. Chambers
Latest version always at https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate
Don't forget to set up port forwarding on your router!  The default port is 25565 and the Bedrock port is 19132
Port used: 25565
Bedrock port used: 19132
Updating to most recent paperclip version ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   159  100   159    0     0    112      0  0:00:01  0:00:01 --:--:--   112
Latest paperclip build found: 132
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 36.3M  100 36.3M    0     0   105M      0 --:--:-- --:--:-- --:--:--  106M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11520  100 11520    0     0   9956      0  0:00:01  0:00:01 --:--:--  9965
Floodgate is up to date
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 11508  100 11508    0     0  10003      0  0:00:01  0:00:01 --:--:-- 10006
Geyser is up to date
Starting Minecraft server...
Must be connected to a terminal.

And this is the 'diagnostic events': Container-Show.txt

TheRemote commented 2 years ago

Ahh, interesting, thanks for sharing the "Diagnostic Events" log as well. That one was interesting mostly because I don't see anything to do with our tty options which helps confirm it.

I mean it can't hurt to try the script /dev/null workaround. The log file information supports this conclusion as well as it does seem we are looking at tty / terminal weirdness and that is what this workaround is for. I say let's try it!

I'm pushing a new version of the container now. Can you do a docker pull on the new container (or the Azure equivalent) and try running again to see if there's any change in the log file (particularly the last error message "Must be connected to a terminal")? If this works I will add it to all versions of the containers for sure.

TheRemote commented 2 years ago

There may be another way as well. I could add a NoScreen environment variable that would make it launch the server without screen. You will lose all logging capabilities with this switch but it would otherwise function normally. That's why the other containers are less picky as that is one of the features / enhancements it has but it's not really meant to make it not work on anything and I'm sure people would appreciate just turning that feature off and have it work rather than just not work at all!

Sam7 commented 2 years ago

Logs look slightly different. But still the same error I'm afraid...

Paper Minecraft Java Server Docker + Geyser/Floodgate script by James A. Chambers
Latest version always at https://github.com/TheRemote/Legendary-Java-Minecraft-Geyser-Floodgate
Don't forget to set up port forwarding on your router!  The default port is 25565 and the Bedrock port is 19132
Port used: 25565
Bedrock port used: 19132
Updating to most recent paperclip version ...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   159  100   159    0     0   1527      0 --:--:-- --:--:-- --:--:--  1528
Latest paperclip build found: 132
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  2 36.3M    2  990k    0     0  4567k      0  0:00:08 --:--:--  0:00:08 4564k
100 36.3M  100 36.3M    0     0  90.8M      0 --:--:-- --:--:-- --:--:-- 90.8M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 11520  100 11520    0     0  10134      0  0:00:01  0:00:01 --:--:-- 10140
Floodgate is up to date
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
100 11508  100 11508    0     0   9725      0  0:00:01  0:00:01 --:--:--  9719
Geyser is up to date
Starting Minecraft server...
Script started, output log file is '/dev/null'.
# 
Script done.
Must be connected to a terminal.
TheRemote commented 2 years ago

Got it. Okay, we're going to have to go nuclear on it. I didn't want to have to do it but it's time.

Let's add the "NoScreen" switch! To use this you would actually add it to your template like any of the other environment variables. Just do NoScreen as "Y" or "1", it doesn't matter as it just checks to see if the variable isn't empty so if you put anything it will activate.

This should absolutely prevent it from requiring a terminal at all. It's screen that is causing the problem. Since you have logs via Azure who cares if you lose the volume based logging in your case. This would matter for some people but you have cloud logging anyways so I think the impact will basically be 0 for you!

Sam7 commented 2 years ago

Amazing! Thanks heaps!! That's working now 👌

TheRemote commented 2 years ago

Hey Sam7,

Thanks for bearing with me for all those posts! It's definitely tough to troubleshoot these and it's extra tough when I don't have the platform (I would have loved to have been able to run your template and no question it would have made things easier).

I actually added this feature to every version of my container. I figure statistically speaking that for every person like you patient and willing enough to report it there has to be several people who didn't file an issue or leave a comment to let me know it happened. This should help people across all versions.

I am grateful to you for having the patience and determination to see it through. Definitely enjoy, whether you end up playing with your kids or just want to enjoy some peace and quiet with them occupied! Take care!

cnuland commented 1 year ago

I know this issue is closed but I wanted to call out that I had to add the NoScreen ENV variable for a container running in Kubernetes powered by Cri-O. I think this has to do with some recent changes with many of the non-docker container engines. It might be worth mentioning this in the docs :)

TheRemote commented 1 year ago

Thanks, I will definitely get this added into the docs!

jpinz commented 1 year ago

Hey! I was trying to do this exact thing, deploying on Azure using ACI. And it appears that the NoScreen environment variable is gone. I can't get it to work even though I can't support the -it parameters.

TheRemote commented 1 year ago

I just removed this check. I can't guarantee it will work but the screen application was also removed a while ago.

I'm guessing it will work though if you give it a try. If it doesn't it will be Minecraft itself complaining and not me at least!

EDIT: Something seems wrong with Docker hub so the build is failing. It should come up as soon as Docker Hub decides to work again!

TheRemote commented 1 year ago

Builds are working again on Docker! It says the build for this version finished about 9 minutes ago according to https://hub.docker.com/r/05jchambers/legendary-minecraft-geyser-floodgate

It should be safe to try pulling the latest version and running again here. Hopefully that helps!