Skip to content

A docker container with spigot, builds spigot.jar on first start

Notifications You must be signed in to change notification settings

CraftenDev/docker-spigot

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Minecraft server SPIGIT on Ubuntu 14.04 with openjava 1.8

This docker image builds and runs the spigot version of minecraft.

If the spigot.jar is not found in the minecraft directory the system pulls down BuildTool and build a new spigot.jar from the latest released minecraft.jar

Each time the container is started the presens of the file /minecraft/spigot.jar, if the file is missing a build of spigot.jar is started.

The spigot daemin is started with superovisord, see my Ubuntu container for a more detailed description of my implementation of an init-process in ubuntu, see nimmis/ubuntu

Whats new is

  • selectable memoy size for the java process
  • selectable spigot version
  • do a nice shutdown of the server when the docker stop command is issued
  • docker accessable commands to
    • start/stop/restart the spigot server
    • send console commands to the server
    • look at console output from the server

Why not a precompiled version of spigot is included

Due to legal reasons you can build it yourself but you can't redistribute the finished jar file.

Starting the container

To run the lastest stable version of this docker image run

docker run -d -p 25565:25565 -e EULA=true nimmis/spigot

the parameter

-e EULA=true

The is because Mojang now requires the end user to access their EULA, located at https://account.mojang.com/documents/minecraft_eula, the be able to start the server.

the parameter

-p 25565:25565

tell on witch external port the internal 25565 whould be connected, in this case the same, if you only type -p 25565 it will connect to a random port on the machine

Giving the container a name

To make it easier to handle you container you can give it a name instead of the long number thats normaly give to it, add a

--name spigot

to the run command to give it the name minecraft, then you can start it easier with

docker start spigot
docker stop spigot

First time run

This will take a couple of minuters depending on computer and network speed. It will pull down the selected version on BuildTools and build a spigot.jar from the selected minecraft version. This is done in numerous steps so be patient.

you can follow the output from the compilation with then command (assume that you given the cotainer the name spigot)

docker logs -f spigot
*** open logfile
*** Run files in /etc/my_runonce/
*** Running /etc/my_runonce/set_timezone...
*** Run files in /etc/my_runalways/
*** Running /etc/my_runalways/do_build_spigot...
--2016-12-04 13:17:37--  https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
Resolving hub.spigotmc.org (hub.spigotmc.org)... 104.27.195.96, 104.27.194.96, 2400:cb00:2048:1::681b:c360, ...
Connecting to hub.spigotmc.org (hub.spigotmc.org)|104.27.195.96|:443... connected.
HTTP request sent, awaiting response... 200 OK

Then the compilation is completed the server will start and you will see somethine like

*** Log: Success! Everything compiled successfully. Copying final .jar files now.
*** Log: Copying craftbukkit-1.11-R0.1-SNAPSHOT.jar to /minecraft/build/.
*** Log:   - Saved as craftbukkit-1.11.jar
*** Log: Copying spigot-1.11-R0.1-SNAPSHOT.jar to /minecraft/build/.
*** Log:   - Saved as spigot-1.11.jar
*** Running /etc/my_runalways/eula...
*** Running /etc/rc.local...
*** Booting supervisor daemon...
*** Supervisor started as PID 4820
*** Started processes via Supervisor......
crond                            RUNNING    pid 4824, uptime 0:00:03
spigot                           RUNNING    pid 4825, uptime 0:00:03
syslog-ng                        RUNNING    pid 4823, uptime 0:00:03

you can then exit from the log with CTRL-C

Selecting version to compile

If you don't specify it will always comple the latest version but if you want a specific version you can specifiy it by adding

-e SPIGOT_VER <version>

where is the version you would like to use, to build it with version 1.8 add

-e SPIGOT_VER 1.8

to the docker run line.

versions avaliable

The following version is atm avaliable 1.8, 1.8.3, 1.8.7, 1.8.8, 1.9, 1.9.2 and latest. Please check the webpage for BuildTools to get the latest information.

setup memmory to use

There are two environmentvariables to set maximim and initial memory for spigot.

MC_MAXMEM

Sets the maximum memory to use m for Mb or g for Gb, if this parameter is not set 1 Gb is choosen, to set the maximum memory to 2 Gb

-e MC_MAXMEM=2g

MC_MINMEM

sets the initial memory reservation used, use m for Mb or g for Gb, if this paramter is not set, it is set to MC_MAXMEM, to set the initial size t0 512 Mb

-e MC_MINMEM=512m

look at the last output from the spigot server

To get an output of the latest events from the spigot server type

docker exec spigot mc_log

and you will see the last 10 lines from the output, this is what you will see after startup

Abort with CTRL-C
[13:02:15 INFO]: Zombie Aggressive Towards Villager: true
[13:02:15 INFO]: Experience Merge Radius: 3.0
[13:02:15 INFO]: Preparing start region for level 0 (Seed: 506255305130990210)
[13:02:16 INFO]: Preparing spawn area: 22%
[13:02:17 INFO]: Preparing spawn area: 99%
[13:02:17 INFO]: Preparing start region for level 1 (Seed: 506255305130990210)
[13:02:18 INFO]: Preparing spawn area: 95%
[13:02:18 INFO]: Preparing start region for level 2 (Seed: 506255305130990210)
[13:02:18 INFO]: Server permissions file permissions.yml is empty, ignoring it
[13:02:18 INFO]: Done (3.650s)! For help, type "help" or "?"

It will continue to output everything from the console until you press CTRL-C

sending commands to the server console

You don't need to have an interactive container to be able to send commands to the console. To send a command to set the time to day you type

docker exec spigot mc_send "time set day"

If this was the first command issued after a start the output should look like

[13:02:15 INFO]: Zombie Aggressive Towards Villager: true
[13:02:15 INFO]: Experience Merge Radius: 3.0
[13:02:15 INFO]: Preparing start region for level 0 (Seed: 506255305130990210)
[13:02:16 INFO]: Preparing spawn area: 22%
[13:02:17 INFO]: Preparing spawn area: 99%
[13:02:17 INFO]: Preparing start region for level 1 (Seed: 506255305130990210)
[13:02:18 INFO]: Preparing spawn area: 95%
[13:02:18 INFO]: Preparing start region for level 2 (Seed: 506255305130990210)
[13:02:18 INFO]: Server permissions file permissions.yml is empty, ignoring it
[13:02:18 INFO]: Done (3.650s)! For help, type "help" or "?"
[13:12:35 INFO]: Set the time to 1000

It will continue to output everything from the console until you press CTRL-C

starting and stopping the server

To stop the server but not the container do

docker exec spigot mc_stop

To start it after beeing stopped do

docker exec spigot mc_start

Finaly to restart it do

docker exec spiot mc_restart

stopping the container

When the container is stopped with the command

docker stop spigot

the spigot server is shutdown nicely with a console stop command to give it time to save everything before stopping the container. If you look in the output from the server this show

[13:01:51 INFO]: Stopping the server
[13:01:51 INFO]: Stopping server
[13:01:51 INFO]: Saving players
[13:01:51 INFO]: nimmis lost connection: Server closed
[13:01:51 INFO]: nimmis left the game.
[13:01:51 INFO]: Saving worlds
[13:01:51 INFO]: Saving chunks for level 'world'/Overworld
[13:01:51 INFO]: Saving chunks for level 'world_nether'/Nether
[13:01:51 INFO]: Saving chunks for level 'world_the_end'/The End

Having the minecraft files on the host machine

If you delete the container all your filer in minecraft will be gone. To save them where it's easier to edit and do a backup of the files you can attach a directory from the host machine (where you run the docker command) and attach it to the local file system in the container. The syntax for it is

-v /host/path/to/dir:/container/path/to/dir

To attach the minecraft directory in the container to directory /home/nimmis/mc-srv you add

-v /home/nimmis/mc-srv:/minecraft

Future features

  • automatic backup
  • plugins
  • more....

About

A docker container with spigot, builds spigot.jar on first start

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%