Mincecraft Paper Spigot

docker-compose

Steve Thielemann 29eea5078a Minor changes. 6 лет назад
data da21073e7d Docker stop now: warns, saves, and stops Minecraft 6 лет назад
mc-java 81f4888d5b More cleanup. Image is as small as I can go using python mcstatus. 6 лет назад
docker-compose.yml 19d2fb8e3d Added UID/GID into docker-compose environment. 7 лет назад
readme.md 29eea5078a Minor changes. 6 лет назад

readme.md

Minecraft - docker-compose

This is Minecraft, running under docker, using docker-compose.

Prerequisites

  • Docker
  • docker-compose
  • Possibly docker configured to run as non-root

https://docs.docker.com/engine/installation/linux/linux-postinstall/

Getting Started

  • Edit docker-compose.yml
  • Edit data/server.properties, data/ops.txt
  • Edit data/plugins/ configurations...

In the docker-compose.yml, set UID and GID to the numerical IDs of your current user account. The image will use the default values 1000 as defined the the Dockerfile.

Building Image and Running

  • docker-compose build
  • docker-compose up -d
  • docker-compose logs -f

Or, if you're having errors starting up, just docker-compose up.

This will display the logs to the console. Ctrl-c stops the container. Ctrl-p, Ctrl-q detaches the console.

Deployment

Edit docker-compose.yml file to set the port.

ports:
  - "25565:25565"

The first number is the external port that everyone connects in on, which is the default Minecraft port. The second number is the port the minecraft server listens on.

To use port 20065, change to:

ports:
  - "20065:25565"

Note: You'll need to use 20065 in the Minecraft client to this non-standard port number.

I don't recommend you change the Minecraft port number on the server side. There's no need to with Docker! But, if you really, really want to, here's what you in for:

  • Change the Minecraft port in the server.properties file
  • Change the value following the : in the docker-compose.yml ports settings to the new port number
  • Update Dockerfile EXPOSE line with new port number
  • Update Dockerfile HEALTHCHECK line to localhost:NEW_PORT

Rebuild the image with docker-compose build.

Using Save and Shutdown

This docker image will use rcon to send a message to users, sleep 1 second, issue /save-all, sleep 1 second, and /stop.

In order for this to work rcon must be enabled in server.properties.

In data/server.properties set:

  • rcon.port=25575
  • rcon.password=mindcraft
  • enable-rcon=true

The shutdown message and delays are in the mc-java/launch.sh script in the save_shutdown() function. Be careful making the delays too long! Docker sends SIG_TERM, waits 10 seconds, and then sends SIG_KILL.

Is it safe to enable rcon? Is this secure?

**Yes, so long as you don't expose the rcon port **25575 to the world in docker-compose.yml. If you do expose the rcon port, then you must change the rcon.password and update the docker image launch.sh script. In launch.sh change the rcon port and password information on the line starting with RCON=. Expose the rcon port by adding a line to the ports section of the docker-compose.yml.

Running other Minecraft Servers

This image doesn't just run paper. It'll run any minecraft server. Just grab the server jar file, copy into data directory, edit docker-compose.yml file and edit the environment SERVER value to match the name of your jar file.

Downloading a Newer Server

https://ci.destroystokyo.com/job/PaperSpigot/

Newer Plugins

(need link)

Author

  • Steve Thielemann

Acknowledgments

For giving me my first taste of running minecraft server under docker.

And for the headaches from trying to update minecraft versions that made me want to try to build my own image.