files and folders:
docker-compose.yml
: main fileenv/container.env
: common settings for most serversenv/cmp.env
: settings forcmp
servermods/1.20.1/base
: folder of jar file mods for all serversmods/1.20.1/creative
: folder of jar file mods for creative server onlyservers/cmp
: folder for all server data forcmp
server
You can run this shell script / copy-paste to terminal to create the files & folders:
mkdir -p env servers/cmp mods/1.20.1/base mods/1.20.1/creative
touch docker-compose.yml env/container.env env/cmp.env
version: "3.7"
services:
cmp:
image: itzg/minecraft-server:latest
stdin_open: TRUE
tty: TRUE
stop_grace_period: 15s
restart: on-failure
container_name: "cmp"
ports: ["25565:25565"]
env_file:
# Multiple files are allowed.
# Variables set in multiple files get the value from the last file.
# The files are processed in order so new assignments overwrite old ones.
- "./env/container.env"
- "./env/cmp.env"
environment: # These values overwrite those from env files
EULA: TRUE
VERSION: 1.20.1
TYPE: "FABRIC"
LEVEL: "world"
MOTD: §3Docker Minecraft Server
# `MODS` copies jar files from multiple folders to the `/data/mods` folder in the container on every startup
MODS: "/modfiles/base,/modfiles/creative"
REMOVE_OLD_MODS: "TRUE"
OVERRIDE_SERVER_PROPERTIES: "TRUE"
# Optional UID / GID.
# Uncomment & set these if you get errors about read/write permissions for mounted files
# UID: 1000 # replace with the value of `id -u` from your shell
# GID: 1000 # replace with the value of `id -g` from your shell
volumes:
- "./servers/cmp:/data"
- "./mods/1.20.1:/modfiles:ro"
### Filesystem and JVM
INIT_MEMORY=1G
MAX_MEMORY=4G
# This setting uses a pre-defined set of JVM flags optimized for minecraft.
USE_AIKAR_FLAGS=TRUE
### Docker Image
EULA=TRUE
TYPE=FABRIC
### Container Settings
TZ=America/Los_Angeles
# Autopause when no players are online.
# This pauses the java process and saves resources, and doesn't interfere with chunk-loading within the game
ENABLE_AUTOPAUSE=TRUE
MAX_TICK_TIME=-1
autoheal=FALSE
RCON=TRUE
RCON_PASSWORD=mc
### Whitelist
# https://docker-minecraft-server.readthedocs.io/en/latest/configuration/server-properties/#whitelist-players
ENFORCE_WHITELIST=TRUE
ENABLE_WHITELIST=TRUE
# server.properties
ONLINE_MODE=TRUE
OP_PERMISSION_LEVEL=2
ENFORCE_SECURE_PROFILE=FALSE
# game settings
MODE=CREATIVE
DIFFICULTY=hard
SPAWN_ANIMALS=TRUE
SPAWN_MONSTERS=FALSE
SPAWN_NPCS=TRUE
SPAWN_PROTECTION=0