Dockerfile to run and administrate a vanilla minecraft server easily.
The docker image exposes 3 volumes:
- /minecraft/server : the main directory of the server that contains the map, the server.properties ...
- /minecraft/backup : a backup directory for the server.
- /minecraft/ssh : a directory where to place your id_rsa and id_rsa.pub in order to store your backup remotely.
It's mandatory that you MAP the volume /minecraft/server if you want to access the MAP and the server configuration. You can also provide your own map and server configuration in this volume, the server will use it on startup.
This docker image allows you to administrate your minecraft server using the command minecraft
Here is a few example:
- backup the map and the server.properties:
minecraft backup - give administrator rights to a player:
minecraft command op player-name - stop the server properly:
minecraft stop - get a property of the minecraft server:
minecraft property level-name - change a property of the minecraft server:
minecraft property view-distance 15 - get a configuration of this wrapper:
minecraft config min-heap - change a configuration of this wrapper:
minecraft config max-heap 8192 - change the version of minecraft:
minecraft set-version 20w17a - ...
All these commands can be sent remotely using the RCON protocol on the port 25575 (See Remote management)
If you want to run a durable instance, you can configure the auto-clean feature:
- add the option
--auto-cleanto the command line or set the envMC_AUTO_CLEAN=trueto enable it. (the old variable DOCLEANING still works) - when auto-clean is enabled a cleanup is performed daily and keeps 20 days of logs + 40 days of backups (acts on local backups only)
If you want to backup your world frequently you can configure the auto-backup feature:
- add the option
--auto-backupto the command line or set the envMC_AUTO_BACKUP=trueto enable it. (the old variable DOBACKUP still works) - when auto-backup is configured the map is backed-up weekly (by default) using cron. A backup is also performed each time the server is stopped.
- if you want to change the backup frequency then add the option
--backup-frequencyto the command line or set the env MC_BACKUP_FREQUENCY. example:MC_BACKUP_FREQUENCY=daily.
If you would like to run a minecraft server on temporary cloud instance instead of permanently running server you can use the auto-dowload and/or auto-upload.
It requires to configure the ssh-remote-url and add a ssh key to the container.
- to configure it add the option
--ssh-remote-urlto the command line or set the envMC_SSH_REMOTE_URLwith a value of the formuser@server:/path/to/backup/dir - map a volume with and id_rsa and id_rsa.pub file on /minecraft/ssh. (use the following command to create the ssh key if you dont have one:
ssh-keygen -b 4096 - t rsa -f ./id_rsa)
auto-dowload feature :
- add the option
--auto-dowloadto the command line or set the envMC_AUTO_DOWNLOAD=trueto enable it. - when auto-dowload is configured the server looks for the latest backup on the remote server. If the latest backup is not available localy then it downloads it.
auto-upload feature :
- add the option
--auto-uploadto the command line or set the envMC_AUTO_UPLOAD=trueto enable it. - when auto-upload is configured, each time server performs a backup the file is uploaded on the remote.
This image contains a RCON server that allows you to send it commands remotely like on the RCON port of the minecraft server.
If your RCON command starts with minecraft then it will interpreted by this server like one of any command you could use inside of this image.
Any other command will be forwarded to the minecraft server if it's running.
To build the latest release of minecraft:
$ makeTo build the latest snapshot of minecraft:
$ make latest-snapshotTo clean all minecraft running container and minecraft images:
$ make cleanYou have also an help:
$ make helpExample to build the snapshot 1.12-pre6 of minecraft:
$ docker build --build-arg MINECRAFT_VERSION=1.12-pre6 -t overware/minecraft-vanilla:1.12-pre6 ./You can change default JVM : Max Heap / Min Head, with environment variables :
- MC_MAX_HEAP=6144 (MAXHEAP also works)
- MC_MIN_HEAP=2048 (MINHEAP also works)
To customize your server.properties instance, you can specify parameter by adding docker environment variable prefix by MCCONF_. For example :
- MCCONF_motd=Name of your Minecraft server
- MCCONF_max-players=Number max of simultaneous players
- MCCONF_view-distance=Number of max chunck view distance
- MCCONF_difficulty=Difficulty level
- MCCONF_level-seed=Seed of your world
- MCCONF_...
To start an instance:
$ docker run -d -p 25565:25565 -v directory-to-myserver-config:/minecraft/server -v directory-to-store-backups:/minecraft/backup --name minecraft-vanilla overware/minecraft-vanilla:latestIf you already have a backup of your world in /minecraft/backup and no world in /minecraft/server, the container will automatically take the last backup from your backup folder and use it as your minecraft world.
To stop it, if you have enabled auto-backup, let the container enough time to do it before stopping:
docker stop -t 60 minecraft-vanillaIf you want to manually backup your world:
$ docker exec -ti minecraft-vanilla backupThis and example of docker compose configuration:
version: "3"
services:
minecraft-vanilla:
image: overware/minecraft-vanilla:1.15.2
ports:
- "25565:25565"
- "25575:25575"
environment:
- MC_AUTO_CLEAN=True
- MC_AUTO_BACKUP=True
- MCCONF_motd=Localhost Minecraft Test Server
- MCCONF_level-name=test-world
#- MC_AUTO_DOWNLOAD=True
#- MC_AUTO_UPLOAD=True
#- MC_SSH_REMOTE_URL=user@server:/path/to/backup/dir
#volumes:
# - "./ssh/:/minecraft/ssh/:ro"
command:
serve -v --backup-frequency daily