fetches and launches the latest minecraft jar + automated server updates and world backups
726
Docker Minecraft Server
This image downloads and runs the latest (Java) Minecraft server, with some extra features. Source code is here: https://github.com/chamer81/docker-minecraft
The container exposes three volumes:
WARNING: you must update the eula.txt file yourself (in the data volume). On the first run, the server generates this file (and others) and exits. In order to actually run the server, you must set the value eula=true in that file to indicate that you accept the End User License Agreement of the Minecraft server (see: https://account.mojang.com/documents/minecraft_eula). After updating the file, the server should run on the next launch. It's quite simple to automate placing a completed eula.txt in the data directory before the first launch -- I am not providing this for legal reasons, not technical reasons.
Here's an example docker-compose.yml file to run it:
version: '3.3'
services:
minecraft:
image: chamer81/minecraft:latest
restart: always
volumes:
- <your minecraft data dir>:/etc/minecraft/data:rw
- <your minecraft backups dir>:/etc/minecraft/backups:rw
- <your minecraft server jar dir>:/etc/minecraft/bin:rw
ports:
- "25565:25565"
environment:
CUSTOM_BACKUP_TIME: 0620
NUM_SERVERS: 1
If you don't set a custom backup time, the default is 0530 (i.e. 5:30). After backing up the world data, the python script in the container checks for an updated server jar (and automatically updates if necessary).
The backups are stored using hard-links to avoid re-writing any redundant data -- so your latest backup won't increase your backup storage size by much on days when the world doesn't change much. There is no built-in cleanup of the backups, so you might want to throw some away from time to time.
There is an additional feature in this container setup that allows you to send commands to the server by writing them to the file cmdfile in the data volume. So, for example, to set the time to day in your server, go to your minecraft data volume and run the following command:
echo "time set day" > cmdfile
The command reader script will run the command in the server and delete it from the cmdfile.
Note that to restart the server, you can run the "stop" command (using the command file). This will cause the minecraft server (and the entire docker container) to exit. Then, if you have run the container with restart: always (as illustrated in the above docker-compose.yml file), it will restart automatically.
You can use this image to run multiple minecraft servers on the same machine as long as you use different host ports, data volumes, and backup volumes. It is OK for them to share the same volume for minecraft server binaries -- but in that case, don't launch them simultaneously, and be sure to stagger their backup times so that they won't try to download the new server binaries to the same place at the same time. Additionally, it is good to set the NUM_SERVERS environment variable to the number of servers you intend to run (to optimise use of RAM).
Sometimes it takes a few attempted connections (about 3 or 4) to get the world built and to successfully connect after launching a new server container. The first error message is that the connection is refused, the next is that it timed out (while the server is actually preparing the world data). After that, wait a few minutes, and you should be able to connect -- and all further connections to that server should work.
Content type
Image
Digest
sha256:55c1b8186…
Size
161 MB
Last updated
over 2 years ago
docker pull chamer81/minecraft