All HowTo's Kubernetes & Docker Linux Ubuntu, Mint & Debian Linux

Host Your Own Private MineCraft Server in 2 Minutes

This article aims to show how you can host your own Minecraft server running in a Docker container in around 2 minutes. The starting point is a working Ubuntu server, but because we’re using Docker, it could be any system that allows you to run Docker containers. I’m using Ubuntu, which impacts the packages to install and directory locations.

Install Docker:

apt update
apt install docker docker-compose docker.io

Prepare the directory structure:

mkdir /opt/minecraft
mkdir /opt/minecraft/data
cd /opt/minecraft

Prepare the Docker compose file “/opt/minecraft/docker-compose.yml” with the following content:

services:
  mc:
    image: itzg/minecraft-server
    tty: true
    stdin_open: true
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
    volumes:
      - ./data:/data
    restart: always

Note: The EULA line in the above means that you are accepting the end user agreement.

Start the container:

docker-compose up -d

To stop your Docker container – without losing anything because the data is stored on the system in the “./data” location:

docker-compose down

The Docker container will auto start when Docker (the service) starts.

The default port to listen on is “tcp/25565”. If you want to allow those outside of your network to access your Minecraft server, you may need to port forward that port from the router to the Minecraft server.

The “server.properties” file lives in the “./data” directory. Any changes to that file requires you to bring the Docker container down and then back up again – using the commands above.

Leave a Reply

Your email address will not be published. Required fields are marked *