Skip to content

About

Using docker compose to setup a vanilla minecraft server.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

114 Commits

Folders and files

Repository files navigation

Minecraft Server Setup

This repository contains the setup for setting up a minecraft server without having to install your own version of Java. This setup only supports vanilla minecraft for the time being.

Setup includes the following:

  • Selects the Java version appropriate for the server version.
  • Downloads the correct server version for you, given availability.
  • Gets you started straight to server setup.

Requirements:

  • Docker - Needed for this setup. Great for quickly spinning up an environment for the server.
  • Linux, Mac or WSL for Windows - Needed to use bash commands.

Optional:

  • Make - CLI to easily execute scripts given in the Makefile.

Steps:

Note: Main scripts will have you agree to Minecraft's EULA.

Scripts:

  • Windows: Execute the file run.bat
  • Mac/Linux: Execute the file run.sh in terminal.

Starting up the MC server right away for the first time:

Each scripts have their dedicated help commands. Makefile has the make help command for their equivalents.

Scripts

  1. Use the command server and then type your desired Minecraft version.

Re-running the same server again command is run-server.

Makefile

  1. Run the command make server [MC version] to start your new minecraft server instance.

Re-running the same server again command is make up

Post setup:

  • You will be given direct access to the server CLI.
    • Enter command stop in the server CLI to close the server. Recommended for graceful exit.
    • You can alternatively use Ctrl-C but generally not recommended.
  • JVM arguments can be set in docker-compose.yaml file in the command line.
  • The server files will be populated in the out folder so that users can access them and backup anytime.
    • The out folder will initially not be there. It will be created before the server runs.

Notes

  • It is a good idea to backup the out/world data incase you want to reload the world again.
  • Try to git pull if the newest server version is not supported.
  • Type git clean -fd to restore the project after tinkering. Does not remove contents from out directory.
    • There is a github action that auto-populates the server versions every 24 hours.
  • Currently the docker setup does not support showing the GUI app generated from server.jar, so including --nogui after the jar file path is crucial.
    • Currently no plan to adding GUI support to containers due to current complexity.
    • Requires different setup depending on OS.

Extras

WARNING: Not for those new to docker.

Environment only image

There is a build stage where only the JRE environment is made without downloading the server. Can be great for trying out other modded servers.

Note the instructions makes use of Makefile commands.

You can start up an instance by going to the existing docker-compose.yaml and change the following:

  1. Change the target value in build from minecraft-server to env-base.
  2. Run make image [MC Version] to build env-base image. Excludes downloading the server.jar file.
  3. Place the server JAR file in this directory. Recommended to rename the JAR file to server.jar.
  4. Uncomment the volume bind for the server JAR in the yaml file.
  5. Run make up to start the container.

Disclaimer: Modded servers are not guaranteed to work with this setup as they may need extra JRE modules.

Different C Libraries

Currently there are two dockerfiles available for setup. They have extensions based on C library names.

Supported C libraries:

If you want to try musl, just create a file with the filename clib.env in this project directory and then paste the following text to the file:

C_LIB=musl

You can later either remove the file or change the value from musl to glibc if you want to go back to using glibc.

musl is only there for experimental purposes, glibc is recommended due to it being more fit for purpose for running minecraft servers and is the reason why it's currently set as the default in the docker-compose file.

Image Without a Mount

Currently the image build can support standalone setup without any binding but is recommended to use the current docker compose setup as the mount setup is good in general use cases.

This setup as a hobby project to get to know docker more.

Pre-setup:

  1. Generate the .env file using the convenient make setup-env [MC_VERSION]

Preparing the setup for building a standalone image:

In the docker-compose.yaml file:

  1. Uncomment the line where it says MINECRAFT_EULA=TRUE.
  2. Comment the line where it says - ./out:/mnt/server-files/${UID:-65532}_${GID:-65532}.

Extra step for linux/mac users: Remove the variables UID and GID from the generated .env file.

Build Phase:

  1. Run docker compose build to build the image.

The name of the image shown in the output should look something like minecraft.vanilla.server:glibc-1.21.11 assuming 1.21.11 is the MC_VERSION chosen.

  1. You can run the standalone container via the command:
docker run --rm -it -p 25565:25565 IMAGE_NAME

Replacing IMAGE_NAME with the name of the generated image.

Credits

  • Mojang Studios for providing the server JARs and metadata.
  • liebki's repo for reference to auto-update github action and having populated most server links.

About

Using docker compose to setup a vanilla minecraft server.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages