This guide has been written as a good reference to getting a Minecraft server running within a Docker container.

Lastly is the order in which things need to be done.

  1. Create and save the scripts where they need to go. Refer to the FS layout below.
  2. Download the jar file and save it where it needs to go. Refer to the FS layout below.
  3. Create your dockerfile, and create your container.
  4. Run container to test it
  5. Ensure you can connect to it with the Minecraft client.


We are going to keep this lean, only adding in tmux, vim, wget, and curl for quality of life issues.

    FROM centos:latest

    RUN yum -y install deltarpm
    RUN yum -y update
    RUN yum -y install tmux \
                       java-1.8.0-openjdk \
                       vim \
                       wget \
                       curl \

    RUN yum -y clean all

    RUN useradd minecraft

    USER minecraft 
    ENV HOME /home/minecraft
    CMD /bin/bash
    ENTRYPOINT ["/bin/bash","/home/minecraft/"]

Docker launch script

We will need a script to launch this container. I use volumes to make life easier, both retaining world data, but also facilitating some (albeit not full) automation.

    docker run -ti --rm\
           --name=minecraft \
           -p=25565:25565 \
           -m=1g \
           -v=/storage/docker/minecraft:/home/minecraft:z \

Minecraft start script

This is the script inside the container that will fire up Minecraft. You want this in the volume's root that you pass in. Since in this example we have passed /storage/docker/minecraft in as /home/minecraft, we want this script at the /storage/docker/minecraft location.

The following script also has a line for determining the newest filename, so when you update, you can wget/curl the correct file in and restart the container.

    cd /home/minecraft
    FILENAME=`ls -t minecraft_server* | head -1`
    java -server -Xmx256M -jar $FILENAME nogui

Managing the container

Run this to enter the container to manage it:

    docker exec -it minecraft bash

Simple volume file structure

Sanitized ls of my volume as the container sees it:

    $ docker exec -it minecraft bash
    bash-4.2$ cd /home/minecraft/
    bash-4.2$ ls -1