Docker Community Forums

Share and learn in the Docker community.

High Memory consumption in Docker on ARM (minecraft-java)

This might be system specific:
Im running Ubuntu 20.04.2 LTS
uname -a
Linux MC-Main 5.4.0-1046-oracle #50-Ubuntu SMP Fri May 14 19:23:11 UTC 2021 aarch64 aarch64 aarch64 GNU/Linux

running paper.jar like this:
java -Xms512M -Xmx2048M -jar server.jar nogui

this creates the desirable result, server boots up and is ready to go

using popular plugin (tabtps) i can see the server is using 500-1000mb ram in idle
running sudo pmap <ID> i can see it’s using approx the same tabtps reports

obviosly joining the server and moving arround would make the ram go upto 2000mb

now because I want to easily deploy and destory servers I wrote this dockerfile

creating the image like this
docker build -t mc-no-plugin-speedrun .

FROM openjdk:16
COPY . /app
CMD ["java", "-Xms512M", "-Xmx2048M", "-jar", "server.jar", "nogui"]

and finally running the compose file
docker-compose -f speedrun5.docker-compose.yaml -p speedrun up -d

version: "3.3"

  container_name: speedrun5
  stdin_open: true # docker run -i
  tty: true        # docker run -t
  image: "mc-no-plugin-speedrun:latest"
   dockerfile: dockerfile
   context: ./speedrun_template
   - 25515:25565

the server boots up and is available on port 25515
tabtps reports 500-1000mb ram when i run it ingame or thru shell
exactly the same as without docker

however running docker stats or just htop
reports the container using about 2.500GiB doing absolutely nothing with 0 players and 0 or 1 plugins (tabtps)

using this image with 100+M download and configuring it to use paper with a maximum of 8gb ram uses 3.4GiB on starts and when I let it sit just for good measure (compleate world gen or whatever) uses EVEN MORE memory

CONTAINER ID   NAME        CPU %     MEM USAGE / LIMIT     MEM %     NET I/O           BLOCK I/O        PIDS
892948910cc6   speedrun4   11.21%    4.17GiB / 23.32GiB    17.88%    79.6kB / 2.74kB   32.8MB / 459kB   48

I know that papermc can work in docker on x86 without problems with like 500mb ram on idle
so i assume ARM is the culprit?

I really really dont know how to run papermc inside docker without wasting about 2-3x the ram

can you please help me run papermc inside docker on my system?

things i tried:

  • diffrent images - same issue
  • even more different images - no arm64v8 support
  • alpine + zulu java - same issue
  • removing stdin_open and tty from docker-compose - same issue
  • making a bare alpine container, installing java, wget minecraft and running it - same issue
  • limiting docker container to 3gb ram - same issue
  • changing to -Xms112M -Xmx248M - expected behaviour (error and crash)
  • copying someones java arguments like -XX:+UseG1GC (and like 30 others) - same issue
  • running docker and bare metal side by side, comparing processes - docker eate what docker stats says, normal java process eate what tabtps said

inside the container tabtps


host docker stats
42ad44f3d6c8 speedrun1 11.29% 2.353GiB / 23.32GiB 10.09% 44MB / 272kB 377kB / 414kB 50

do you know how to host papermc inside docker?

I dont wanna limit all servers to min-max 1gb, because then they can’t scale with more players
and having a server use 3gb with no players is a waste of ressources :frowning: