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.56k forks source link

EULA on startup #147

Closed HDPete closed 7 years ago

HDPete commented 7 years ago

I have installed the Docker ITZG Minecraft Server package on my QNAP NAS as a Container, with the following parameters, but the container will not start as it keeps reporting that I need to add -e EULA=TRUE

docker run -d -it -e EULA=TRUE -p 25565:25565 --name mc itzg/minecraft-server /start

Error received:

Please accept the Minecraft EULA at
https://account.mojang.com/documents/minecraft_eula
by adding the following immediately after 'docker run':
-e EULA=TRUE

Switching to user 'minecraft'

screen shot 2017-05-06 at 19 59 12
itzg commented 7 years ago

@HDPete since I have not used that HW/SW I found some clues here where it sounds like you'll need to set the EULA environment variable over in the "Advanced settings >>" area, such as here:

image

For "command" just leave it blank since no further arguments need to be passed to the entrypoint /start script. Confusingly even though docker run ... would be considered a "command" by most people, when Docker refers to the "command" it's just the bit after the IMAGE shown in the docs here.

peterrus commented 7 years ago

I am having trouble setting EULA to TRUE at all, so maybe this functionality is broken currently, but hasn't been noted because you only set it once.

I am using the following docker-compose file, maybe it helps:

version: "2"

services:
  minecraft:
    ports:
      - "25565:25565"

    environment:
      - EULA=TRUE
      - OPS=someone
      - PVP='false'
      - MEMORY=2G
      - SPAWN_MONSTERS='true'

    image: itzg/minecraft-server

    container_name: minecraft

    tty: true
    stdin_open: true
    restart: always

    volumes:
     - minecraft-data:/data

volumes:
  minecraft-data:

( have used numerous variations on setting the environment variable btw)

itzg commented 7 years ago

@peterrus , weird, I saved your compose above to a file and it started up fine for me:

➜  /tmp/issue147 docker-compose pull
Pulling minecraft (itzg/minecraft-server:latest)...
latest: Pulling from itzg/minecraft-server
cfc728c1c558: Pull complete
2edf86b96d46: Pull complete
8fcc070dd983: Pull complete
9d2670aac311: Pull complete
47c0f9c9a473: Pull complete
f0cc04bc365a: Pull complete
2deedb16981b: Pull complete
0100233195d0: Pull complete
15c3a0543698: Pull complete
0fa95bb5b82c: Pull complete
Digest: sha256:228545d3a58853b0fd26d2ed268904f92e32bdf850c43bbe2e27c946403e5934
Status: Downloaded newer image for itzg/minecraft-server:latest
➜  /tmp/issue147 docker-compose up
WARNING: The Docker Engine you're using is running in swarm mode.

Compose does not use swarm mode to deploy services to multiple nodes in a swarm. All containers will be scheduled on the current node.

To deploy your application across the swarm, use `docker stack deploy`.

Creating network "issue147_default" with the default driver
Creating volume "issue147_minecraft-data" with default driver
Creating minecraft
Attaching to minecraft
minecraft    | g to user 'minecraft'
minecraft    | Checking version information.
minecraft    | Checking type information.
minecraft    | Downloading minecraft_server.1.11.2.jar ...
minecraft    | Creating server.properties
minecraft    | Setting motd to A Minecraft Server Powered by Docker
minecraft    | Setting spawn-monsters to 'true'
minecraft    | Setting enable-rcon to true
minecraft    | Setting rcon.password to minecraft
minecraft    | Setting rcon.port to 25575
minecraft    | Setting level-name to world
minecraft    | Setting pvp to 'false'
minecraft    | Setting online-mode to TRUE
minecraft    | Setting level type to DEFAULT
minecraft    | Setting difficulty to 1
minecraft    | Setting ops
minecraft    | Setting initial memory to 2G and max to 2G
minecraft    | + [[ VANILLA == \F\E\E\D\-\T\H\E\-\B\E\A\S\T ]]
minecraft    | + '[' -f /data/bootstrap.txt ']'
minecraft    | + exec java -XX:+UseG1GC -Xms2G -Xmx2G -jar minecraft_server.1.11.2.jar
minecraft    | [14:59:49] [Server thread/INFO]: Starting minecraft server version 1.11.2
minecraft    | [14:59:49] [Server thread/INFO]: Loading properties
minecraft    | [14:59:49] [Server thread/INFO]: Default game type: SURVIVAL
minecraft    | [14:59:49] [Server thread/INFO]: Generating keypair
minecraft    | [14:59:50] [Server thread/INFO]: Starting Minecraft server on *:25565
minecraft    | [14:59:50] [Server thread/INFO]: Using epoll channel type
minecraft    | [14:59:50] [Server thread/WARN]: Failed to load white-list: 
minecraft    | java.io.FileNotFoundException: whitelist.json (No such file or directory)
minecraft    |  at java.io.FileInputStream.open0(Native Method) ~[?:1.8.0_121]
minecraft    |  at java.io.FileInputStream.open(FileInputStream.java:195) ~[?:1.8.0_121]
minecraft    |  at java.io.FileInputStream.<init>(FileInputStream.java:138) ~[?:1.8.0_121]
minecraft    |  at com.google.common.io.Files.newReader(Files.java:86) ~[minecraft_server.1.11.2.jar:?]
minecraft    |  at mx.g(SourceFile:136) ~[minecraft_server.1.11.2.jar:?]
minecraft    |  at lg.C(SourceFile:123) [minecraft_server.1.11.2.jar:?]
minecraft    |  at lg.<init>(SourceFile:30) [minecraft_server.1.11.2.jar:?]
minecraft    |  at lh.j(SourceFile:186) [minecraft_server.1.11.2.jar:?]
minecraft    |  at net.minecraft.server.MinecraftServer.run(SourceFile:436) [minecraft_server.1.11.2.jar:?]
minecraft    |  at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
minecraft    | [14:59:50] [Server thread/INFO]: Preparing level "world"
minecraft    | [14:59:52] [Server thread/INFO]: Preparing start region for level 0
minecraft    | [14:59:53] [Server thread/INFO]: Preparing spawn area: 5%
minecraft    | [14:59:54] [Server thread/INFO]: Preparing spawn area: 9%
minecraft    | [14:59:55] [Server thread/INFO]: Preparing spawn area: 14%
minecraft    | [14:59:56] [Server thread/INFO]: Preparing spawn area: 21%
minecraft    | [14:59:57] [Server thread/INFO]: Preparing spawn area: 27%
minecraft    | [14:59:58] [Server thread/INFO]: Preparing spawn area: 35%
minecraft    | [14:59:59] [Server thread/INFO]: Preparing spawn area: 41%
minecraft    | [15:00:00] [Server thread/INFO]: Preparing spawn area: 47%
minecraft    | [15:00:01] [Server thread/INFO]: Preparing spawn area: 52%
minecraft    | [15:00:02] [Server thread/INFO]: Preparing spawn area: 58%
minecraft    | [15:00:03] [Server thread/INFO]: Preparing spawn area: 67%
minecraft    | [15:00:04] [Server thread/INFO]: Preparing spawn area: 75%
minecraft    | [15:00:05] [Server thread/INFO]: Preparing spawn area: 85%
minecraft    | [15:00:06] [Server thread/INFO]: Preparing spawn area: 94%
minecraft    | [15:00:07] [Server thread/INFO]: Done (16.258s)! For help, type "help" or "?"
minecraft    | [15:00:07] [Server thread/INFO]: Starting remote control listener
minecraft    | [15:00:07] [RCON Listener #1/INFO]: RCON running on 0.0.0.0:25575
itzg commented 7 years ago

Can you try changing your compose file to add "env" as the entrypoint:

services:
  minecraft:
    # ...
    image: itzg/minecraft-server

    entrypoint: env

and confirm you see the EULA value as shown:

Attaching to minecraft
minecraft    | r/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
minecraft    | HOSTNAME=52f8e03a50d2
minecraft    | TERM=xterm
minecraft    | PVP='false'
minecraft    | MEMORY=2G
minecraft    | EULA=TRUE
minecraft    | OPS=someone
minecraft    | SPAWN_MONSTERS='true'
minecraft    | affinity:container==632d04797c2c17476437669e3724ab3f51cfc3ac476b515507637f4302446704
minecraft    | UID=1000
minecraft    | GID=1000
minecraft    | MOTD=A Minecraft Server Powered by Docker
minecraft    | JVM_XX_OPTS=-XX:+UseG1GC
minecraft    | TYPE=VANILLA
minecraft    | VERSION=LATEST
minecraft    | FORGEVERSION=RECOMMENDED
minecraft    | LEVEL=world
minecraft    | DIFFICULTY=easy
minecraft    | ENABLE_RCON=true
minecraft    | RCON_PORT=25575
minecraft    | RCON_PASSWORD=minecraft
minecraft    | LEVEL_TYPE=DEFAULT
minecraft    | GENERATOR_SETTINGS=
minecraft    | WORLD=
minecraft    | MODPACK=
minecraft    | ONLINE_MODE=TRUE
minecraft    | CONSOLE=true
minecraft    | HOME=/root
^CGracefully stopping... (press Ctrl+C again to force)
peterrus commented 7 years ago

via above debugging method I found out that my env var was filled with "TRUE" instead of TRUE (without the "). I missed that for some reason. Thanks for helping me out so quickly! Also sorry for hijacking the thread, seems to be a different issue than mine then.

itzg commented 7 years ago

You're very welcome. Glad you figured it out.

itzg commented 7 years ago

@HDPete have you been able to resolve the setting of environment variables in QNAP?

HDPete commented 7 years ago

Will have a play this weekend

Peter

On 27 May 2017, at 01:56, Geoff Bourne notifications@github.com<mailto:notifications@github.com> wrote:

@HDPetehttps://github.com/hdpete have you been able to resolve the setting of environment variables in QNAP?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/itzg/dockerfiles/issues/147#issuecomment-304415542, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AbK-VZpConeANc1cgvBCBF0Wu0Sag80Hks5r93S0gaJpZM4NS3wV.

HDPete commented 7 years ago

Hi,

Yes! I got the EULA=true sorted on the QNAP Container Station by configuring it as an Environment Setting when creating the container - it seems you can't edit or append to these settings once created, so it's a bit of a pain.

Also, in order to 'add' EULA=True, the QNAP requests that you delete empty / null variables before adding a new one.

I think this may be causing me a problem, as I have to delete the following empty variables, which result in the server not starting:

GENERATOR_SETTINGS MODPACK WORLD

When I've deleted the above and added EULA True, the container runs up OK but stops after the following errors. I'm by far an expert, but this suggests that there's something up with the path to either Java or the .jar file. Do I need to install other containers other then the ITZG one?

My Run command is:

docker run -d -it -p 25565:25565 --name mc itzg/minecraft-server /start

Results are:

Switching to user 'minecraft'
Checking version information.
Checking type information.
Setting initial memory to 1G and max to 1G

peterrus commented 7 years ago

You should not need any other containers ;) looks like a json file is wrongly formatted. Are you sure your whitelist and ops file are correct? (Are there other files I am forgetting?)

On Sat, Jul 29, 2017, 19:15 HDPete notifications@github.com wrote:

Hi,

Yes! I got the EULA=true sorted on the QNAP Container Station by configuring it as an Environment Setting when creating the container - it seems you can't edit or append to these settings once created, so it's a bit of a pain.

Also, in order to 'add' EULA=True, the QNAP requests that you delete empty / null variables before adding a new one.

I think this may be causing me a problem, as I have to delete the following empty variables, which result in the server not starting:

GENERATOR_SETTINGS MODPACK WORLD

When I've deleted the above and added EULA True, the container runs up OK but stops after the following errors. I'm by far an expert, but this suggests that there's something up with the path to either Java or the .jar file. Do I need to install other containers other then the ITZG one?

My Run command is:

docker run -d -it -p 25565:25565 --name mc itzg/minecraft-server /start

Results are:

Switching to user 'minecraft' Checking version information. Checking type information. Setting initial memory to 1G and max to 1G

  • [[ VANILLA == \F\E\E\D-\T\H\E-\B\E\A\S\T ]]

  • '[' -f /data/bootstrap.txt ']'

  • exec java -XX:+UseG1GC -Xms1G -Xmx1G -jar minecraft_server.1.12.jar docker run -d -it -p 25565:25565 --name mc itzg/minecraft-server [17:07:27] [Server thread/INFO]: Starting minecraft server version 1.12 [17:07:27] [Server thread/INFO]: Loading properties [17:07:27] [Server thread/INFO]: Default game type: SURVIVAL [17:07:27] [Server thread/INFO]: Generating keypair [17:07:28] [Server thread/INFO]: Starting Minecraft server on :25565 [17:07:28] [Server thread/INFO]: Using default channel type [17:07:29] [Server thread/ERROR]: Encountered an unexpected exception* com.google.gson.JsonParseException: java.io.EOFException: End of input at line 2 column 1 path $ at ra.a(SourceFile:506) ~[minecraft_server.1.12.jar:?] at ra.a(SourceFile:522) ~[minecraft_server.1.12.jar:?] at pn.g(SourceFile:141) ~[minecraft_server.1.12.jar:?] at nw.A(SourceFile:99) ~[minecraft_server.1.12.jar:?] at nw.(SourceFile:25) ~[minecraft_server.1.12.jar:?] at nx.j(SourceFile:188) ~[minecraft_server.1.12.jar:?] at net.minecraft.server.MinecraftServer.run(SourceFile:434) [minecraft_server.1.12.jar:?]

  • at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]

  • Caused by: java.io.EOFException: End of input at line 2 column 1 path $ at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1393) ~[minecraft_server.1.12.jar:?] at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:549) ~[minecraft_server.1.12.jar:?] at com.google.gson.stream.JsonReader.peek(JsonReader.java:425) ~[minecraft_server.1.12.jar:?] at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:74) ~[minecraft_server.1.12.jar:?] at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) ~[minecraft_server.1.12.jar:?] at ra.a(SourceFile:504) ~[minecraft_server.1.12.jar:?] ... 7 more [17:07:29] [Server thread/ERROR]: This crash report has been saved to: /data/./crash-reports/crash-2017-07-29_17.07.29-server.txt [17:07:29] [Server thread/INFO]: Stopping server [17:07:29] [Server Shutdown Thread/INFO]: Stopping server

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/itzg/dockerfiles/issues/147#issuecomment-318845068, or mute the thread https://github.com/notifications/unsubscribe-auth/ABEOojgHhEBMNytk8fx8ozrs4heRGpykks5sS2i-gaJpZM4NS3wV .

HDPete commented 7 years ago

Here's a crash dump report, if that helps:

---- Minecraft Crash Report ---- // I blame Dinnerbone.

Time: 7/29/17 5:31 PM Description: Exception in server tick loop

com.google.gson.JsonParseException: java.io.EOFException: End of input at line 2 column 1 path $ at ra.a(SourceFile:506) at ra.a(SourceFile:522) at pn.g(SourceFile:141) at nw.A(SourceFile:99) at nw.(SourceFile:25) at nx.j(SourceFile:188) at net.minecraft.server.MinecraftServer.run(SourceFile:434) at java.lang.Thread.run(Thread.java:745) Caused by: java.io.EOFException: End of input at line 2 column 1 path $ at com.google.gson.stream.JsonReader.nextNonWhitespace(JsonReader.java:1393) at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:549) at com.google.gson.stream.JsonReader.peek(JsonReader.java:425) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:74) at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61) at ra.a(SourceFile:504) ... 7 more

A detailed walkthrough of the error, its code path and all known details is as follows:

-- System Details -- Details: Minecraft Version: 1.12 Operating System: Linux (amd64) version 4.2.8 Java Version: 1.8.0_121, Oracle Corporation Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 993522232 bytes (947 MB) / 1073741824 bytes (1024 MB) up to 1073741824 bytes (1024 MB) JVM Flags: 3 total; -XX:+UseG1GC -Xms1G -Xmx1G IntCache: cache: 0, tcache: 0, allocated: 0, tallocated: 0 Profiler Position: N/A (disabled) Is Modded: Unknown (can't tell) Type: Dedicated Server (map_server.txt)

HDPete commented 7 years ago

I gather that the error is to do with whitespace / null characters in one of the JSON files. Not sure which one. If I delete the JSON files, they get recreated with the same error, so I'm sure that I've found the data folder I need on the NAS.

If I edit the server.properties file offline and re-upload it, I then get a permissions error when running the docker file. I've set the guest access to the file to Full Control but still no joy.

HDPete commented 7 years ago

INTERESTING:

I completely removed Container Station from the QNAP NAS. Deleted it's volumes and historical data. Reinstalled.

Then reinstalled ITZG/Minecraft Latest Version, which had NO repopulated environment settings. I only added EULA=true.

It works - spawn complete.

itzg commented 7 years ago

@HDPete fantastic!

itzg commented 7 years ago

...but to answer your questions, yes, the image takes care of downloading the minecraft server jar and places it in /data. The secondary issue you encountered it caused by 1.12 being intolerant of completely empty JSON files. In the latest image's startup script it tries to fix up empty json files with an empty array.

HDPete commented 7 years ago

Thanks Geoff! Can you possibly confirm whether I should be able to simply edit the server.properties file from any text editor on another machine that has access to that share? I tried earlier, but it seemed to mess the permissions which made the container fail at startup.

itzg commented 7 years ago

You can indeed edit the files via anything that can get at the volume; however, as you mentioned file permissions can be a pain. If can access a Linux view of the volume you should be able to "chmod 666" the file to make it read/writable by all users.

JRitmeester commented 2 years ago

Not trying to necro a 5 year old post, but a comment here helped me:

For people with 0 Docker expierence like me, when installing, go to "Advanced settings" -> "Environment" -> Click "Add" -> Fill in "EULA" (without the quotes) as Name and "TRUE" (without the quotes") as Value. That did the trick for me.

Prateek1815 commented 1 year ago

I have a problem with the command EULA: TRUE it just dosent seem to work.I have 0 docker knowledge so could someone write the exact command for me please.Thanks. environment: EULA: TRUE TYPE: FORGE DEBUG: "false" VERSION: "1.12.2" FORGEVERSION: "14.23.5.2854" GENERIC_PACK: "/modpacks/Astroblock-1.3.3-server-files (1).zip" REMOVE_OLD_MODS: "true" LEVEL_TYPE: "DEFAULT" ENABLE_RCON: "true" LEVEL_SEED: "random"

DFML_QUERYRESULT: "confirm"

  GENERIC_PACK_STRIP_DIRS: 1
  MAX_TICK_TIME: -1
  MEMORY: 20G
  OVERRIDE_SERVER_PROPERTIES: "true"
  RCON_PASSWORD: minecraft
  DISABLE_HEALTHCHECK: "true"
Prateek1815 commented 1 year ago

It also tells me this every time. [19:07:16] [main/INFO] [minecraft/MinecraftServer]: You need to agree to the EULA in order to run the server. Go to eula.txt for more info. 2023-03-03T19:07:16.161Z INFO mc-server-runner Done