itsMaxio / minecraft-docker

Minecraft Server Docker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minecraft Server on Docker

Simple local Docker Image for Minecraft Server vanilla, papermc or custom server.jar (forge too).

How to download

Clone this repo:

git clone https://github.com/itsMaxio/minecraft-docker

Go to the project directory:

cd minecraft-docker

Make scripts executable:

chmod +x ./*.sh

Before start

Make .env file:

cp .env.example .env

Edit 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

Example .env

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 port

If 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, LINK will not work.

If you want to use forge put download link and change TYPE to forge

LINK=https://maven.minecraftforge.net/net/minecraftforge/forge/.../forge-...-installer.jar
TYPE=forge

VERSION doesn'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=25565

How to start

You can use the script included in this repo:

./start.sh

or run it manually (this prevents duplication of images):

docker compose down --rmi all --remove-orphans
docker compose up -d --build

How to stop

You can use the script included in this repo:

./stop.sh

or stop it manually:

docker compose down --rmi all --remove-orphans -t 20

How to attach to container

If you want to attach to container or just enter the console use the script:

./console.sh

or attach manually:

docker attach --detach-keys="@" mcserver

To detach press ctrl + 2 (@) or change --detach-keys="..." as you like.

Only logs (non-interactive)

If you want to see only console logs use the script:

./logs.sh

or do it manually:

docker logs --follow mcserver

Sources

Inspired and based on Docker Minecraft by mtoensing and docker-minecraft-server by itzg.

About

Minecraft Server Docker


Languages

Language:Shell 86.5%Language:Dockerfile 13.5%