Here you can find detailed instructions on how to run a dockerized Minecraft Server using MineOS with docker-compose and create a systemd service to handle it.
Docker
Make sure to have Docker and Docker-compose installed. For Debian Linux you just need to install the following packages.
apt update && apt install -y docker-ce docker-compose
Docker application location
In order to run the container we need to create a location eg: /opt/containers/mineos
and store our configuration in there.
mkdir -p /opt/containers/mineos
Configuration
In order to run the MineOS container we need to specify the following environment variables
- MINEOS_PATH is mandatory and specifies the path in the Host for the container data
- MINEOS_IP is optional and is set when you want the container to listen on a specific IP. In order for it to work you need to add a semicolon at the end. If left blank it will listen to all interfaces.
/opt/containers/mineos/.env defines all necessary environment variables
# MANDATORY - path in the host that will keep mineos data
MINEOS_PATH=/opt/containers/mineos/config
# OPTIONAL - IP of the host that the container will listen on
# MINEOS_IP=192.168.1.2:
Compose File
/opt/containers/mineos/docker-compose.yml defines the services, networks, and volumes for the MineOS Docker application
version: "3"
services:
mineos:
restart: always
image: binhex/arch-mineos-node
environment:
- PUID=0
- PGID=0
# - WEBUI_PASSWORD=mineos # This is the default in the image
ports:
- "${MINEOS_IP}25565-25570:25565-25570"
- "${MINEOS_IP}443:8443"
volumes:
- ${MINEOS_PATH}:/config
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro
Systemd service definition
/etc/systemd/system/docker-compose-mineos.service defines the service that starts and stops the Docker application for the system
[Unit]
Description=MineOS container
Requires=docker.service
After=docker.service
[Service]
Type=simple
WorkingDirectory=/opt/containers/mineos
ExecStart=/usr/bin/docker-compose up --force-recreate --remove-orphans
ExecStop=/usr/bin/docker-compose down
[Install]
WantedBy=default.target
Enable and run service
source /opt/containers/mineos/.env && mkdir -p "${MINEOS_PATH}"
systemctl daemon-reload && \
systemctl enable docker-compose-mineos && \
systemctl start docker-compose-mineos
Visit MineOS UI
You should be able to visit your container at port 443 using the IP you specified in the .env file. eg: https://192.168.1.2