Deploying Minecraft Servers using Docker

dlord

New Member
Jul 29, 2019
147
0
0
docker-logo-loggedout.png


What is Docker?

From their site:

Docker is an open platform for developers and sysadmins to build, ship, and run distributed applications. Consisting of Docker Engine, a portable, lightweight runtime and packaging tool, and Docker Hub, a cloud service for sharing applications and automating workflows, Docker enables apps to be quickly assembled from components and eliminates the friction between development, QA, and production environments. As a result, IT can ship faster and run the same app, unchanged, on laptops, data center VMs, and any cloud.

Long story short, Docker is like a VM. Without the fat. Your app runs on its own world like a VM. Unlike a VM, everything runs directly on the hardware, with negligible impact on performance and memory consumption.


Getting started

For production use, Docker requires Linux. You may use Windows or OSX via boot2docker, but that is considered for development use only. Instructions on how to install Docker on your favorite distro can be found here.

Docker has 2 basic concepts: Images and Containers.

Images are essentially packaged distros, configured to run your app. They are like ISO's: the contents of an image cannot be changed without rebuilding it. Creating images are done either by creating a new container and committing all its changes, or via a Dockerfile.

Containers are the execution environment of your images. Containers run your processes in a sandbox, it has its own view of the file system (separate from the host), and it can be configured to either save or discard all changes on exit.


Running a Dockerized app

Enough with the talk, let's see some action!

You can pull an existing image from the Docker Registry and run it with one command.

For this example, I will use the Material Energy^4 image I recently published:

Code:
docker run --name materialenergy4 -p 0.0.0.0:25565:25565 -d dlord/materialenergy4

This command will do the following for you:
  1. Check if the image dlord/materialenergy4 in your local filesystem, and it will search and pull from the public Docker Registry if not.
  2. Create a new Docker container with the name materialenergy4 via the --name option
  3. Using the -p option, I map the port 25565 from inside the Docker container to the same port on the host. This should make the container accessible to other computers in the network.
  4. Option -d starts the container as a background process.
You need a new instance of Material Energy^4? Just run the same command with a different name and port mapping!


More Information

I highly recommend trying out their tutorial. Also, check out their documentation on how to use it, and roll out your own Docker images.


FTB Modpack Docker Images

I've started creating Docker images for FTB modpacks, which I use for my own deployment. Currently, I have published Material Energy^4, and I'll be adding more as needed.

While these are unofficial images, I have ensured that the images I make are built using FTB's official distribution, and I use the official Docker image for Java 7 as a base. The Dockerfiles used to build these images are public as well.

My Github repository for the Dockerfiles can be found here. If you want to see your favorite FTB modpack dockerized, just file a Github issue, and let's see.

I will be updating this post from time to time as I add more images to my collection.

Here's my list of Docker Images.
 
Last edited:
  • Like
Reactions: Odovbold