Skip to content

Commit

Permalink
updated for non-interactive version
Browse files Browse the repository at this point in the history
  • Loading branch information
nimmis committed Apr 9, 2016
1 parent 5d7cb4f commit 4e01918
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 33 deletions.
13 changes: 5 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@ FROM nimmis/java:openjdk-8-jdk

MAINTAINER nimmis <[email protected]>

#non-interactive installation
ENV DEBIAN_FRONTEND noninteractive

#default directory for SPIGOT-server
ENV SPIGOT_HOME /minecraft

ADD spigot_init.sh /spigot_init.sh
#default version
ENV SPIGOT_VER latest

RUN chmod +x /spigot_init.sh
# add extra files needed
COPY rootfs /

# fast workaround
# add some needed commands
RUN apt-get update && apt-get install -y wget git && apt-get clean all

# Make special user for minecraft to run in
Expand All @@ -22,6 +21,4 @@ RUN useradd -s /bin/bash -d /minecraft -m minecraft
# expose minecraft port
EXPOSE 25565

#set default command
CMD /spigot_init.sh

150 changes: 125 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,33 @@
## Minecraft server SPIGIT on Ubuntu 14.04 with openjava 1.8
[![Docker Hub; nimmis/spigot](https://img.shields.io/badge/dockerhub-nimmis%2Fspigot-green.svg)](https://registry.hub.docker.com/u/nimmis/spigot)

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

Updated to work with version 1.9 (thanks Nikdro)
This is a new version of this container where I have removed the script started at the en and set it up to run spigot as a deamon
with the help of supervisord. See my Ubuntu container for a more detailed description of my implementation of an init-process in
ubuntu, se [nimmis/ubuntu](https://hub.docker.com/r/nimmis/ubuntu/)

## Why not a precompiled version of spigot included
Whats new is
- 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
-

Due to leagal reasons you can build it but not redistribute the finished jar.
## 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 -ti -p 25565:25565 -e EULA=true nimmis/spigot
docker run -d -p 25565:25565 -e EULA=true nimmis/spigot

the parameter

Expand All @@ -36,44 +48,131 @@ you only type -p 25565 it will connect to a random port on the machine
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 minecraft
--name spigot

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

docker start minecraft
docker stop minecraft
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 latest version on BuildTools and build a spigot.jar from the latest minecraft version.
the selected version on BuildTools and build a spigot.jar from the selected minecraft version.
This is done in numerous steps so be patient.

If the compilation was successful the server will start in interactive mode. Log in from a minecraft
client to controll that all works. The type
you can follow the output from the compilation with then command (assume that you given the cotainer
the name spigot)

docker logs -f spigot

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


2016-04-09 12:37:45,392 CRIT Set uid to user 0
*** Started processes via Supervisor......
crond RUNNING pid 28, uptime 0:00:04
spigot RUNNING pid 29, uptime 0:00:04
syslog-ng RUNNING pid 27, uptime 0:00:04


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 <version> 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](https://www.spigotmc.org/wiki/buildtools/#versions) to get the latest information.

## look at the last output from the spigot server

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

to drop back to a root shell in the minecraft directory. Edit and add files to customize your
minecraft server.
docker exec spigot2 mc_log

When you are finished do a
and you will se the last 10 lines from the output, this is what you will se after startup

exit
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 "?"

to exit and stop the container
It will continue to output everything from the console until you press CTRL-C

You can now start it in two different modes, interactive and non-interactive mode.
## sending commands to the server console

## Interactive mode
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

The interactive mode echos server output to the console and you can issue command by type
them in the console. The server stops if you exits the console.
docker exec spigot mc_send "time set day"

## Non-Interactive mode
If this was the first command issued after a start the output should look like

The Non-Interactive mode (daemon mode) starts the server without any output. If you need
to connect and do something with the server you have to use the docker exec command.
[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

Expand All @@ -90,5 +189,6 @@ To attach the minecraft directory in the container to directory /home/nimmis/mc-

## Future features

This is the initial release of this, more features to come.....

- automatic backup
- plugins
- more....

0 comments on commit 4e01918

Please sign in to comment.