Simple local Docker Image for Minecraft Server vanilla, papermc or custom server.jar (forge too).
Clone this repo:
git clone https://github.com/itsMaxio/minecraft-dockerGo to the project directory:
cd minecraft-dockerMake scripts executable:
chmod +x ./*.shMake .env file:
cp .env.example .envEdit variables in .env file:
| Name | Default | Description |
|---|---|---|
JAVA_VERSION |
17-jre-focal | Select Java version |
SERVER_NAME |
mcserver | Specify container name |
VOLUME_PATH |
./server | Specify local path to files |
LINK |
empty | Specify link to a custom server.jar (comment or leave empty if you will not use it) |
TYPE |
papermc | Select server type: vanilla or papermc (or forge see below) |
VERSION |
1.19.2 | Select version e.g.: 1.19.2, 1.17.2 |
UID |
1000 | Specify the UID of user inside container (linux id command) |
GID |
1000 | Specify the GID of user inside container (usually same as UID) |
MINMEMORY |
1G | Specify initial memory (-Xmx) |
MAXMEMORY |
2G | Specify maximum memory (-Xms) |
PORT |
25565 | Specify server port |
JAVA_VERSION=17-jre-focal #Select Java version
SERVER_NAME=mcserver #Specify container name
VOLUME_PATH=./server #Specify local path to files
#LINK= #Download server.jar from link (comment or leave empty if you will not use it)
TYPE=papermc #Select server type: vanilla or papermc
VERSION=1.19.2 #Select version e.g. 1.19.2
UID=1000 #Specify the UID of user inside container
GID=2000 #Specify the GID of user inside container (usually same as UID)
MINMEMORY=1G #Specify initial memory (-Xmx)
MAXMEMORY=2G #Specify maximum memory (-Xms)
PORT=25565 #Specify server portIf you want to use custom .jar file you need to place your server.jar inside /server directory and set TYPE to custom
TYPE=custom
VERSION,LINKwill not work.
LINK=https://maven.minecraftforge.net/net/minecraftforge/forge/.../forge-...-installer.jar
TYPE=forge
VERSIONdoesn't matter.
If you don't create an .env file the default value of variables will be used (via docker-compose.yaml)
JAVA_VERSION=17-jre-focal
VOLUME_PATH=./server
LINK=
TYPE=papermc
VERSION=1.19.2
UID=1000
GID=2000
MINMEMORY=1G
MAXMEMORY=2G
PORT=25565You can use the script included in this repo:
./start.shor run it manually (this prevents duplication of images):
docker compose down --rmi all --remove-orphansdocker compose up -d --buildYou can use the script included in this repo:
./stop.shor stop it manually:
docker compose down --rmi all --remove-orphans -t 20If you want to attach to container or just enter the console use the script:
./console.shor attach manually:
docker attach --detach-keys="@" mcserverTo detach press
ctrl + 2(@) or change--detach-keys="..."as you like.
If you want to see only console logs use the script:
./logs.shor do it manually:
docker logs --follow mcserverInspired and based on Docker Minecraft by mtoensing and docker-minecraft-server by itzg.