Minecraft Server in Docker
Table of Contents
Overview
This project provides a Docker setup for running a Minecraft server. It simplifies the process of setting up and managing Minecraft servers by using Docker, making it easier to deploy and maintain different Minecraft server versions and modpacks.
Why Use Docker for Minecraft Server?
Running a Minecraft server in a Docker container offers several advantages:
- Isolation: Each server runs in its own environment, reducing conflicts with other software.
- Portability: Easily move your server setup between different machines.
- Consistency: Ensure that the server runs in the same environment every time, reducing issues related to system differences.
Prerequisites
- Git and Docker Engine installed on your machine.
- Basic familiarity with Docker commands.
Tested On
Ubuntu Server 22.04 with:
Installation
-
Clone the Repository
git clone https://github.com/FilipRokita/minecraft-server-docker
-
Rename the Repository Folder
mv minecraft-server-docker mcsrv
-
Edit Dockerfile (if needed)
-
Build Container and Create Symlink
-
Download Server Files
- Download the Minecraft server files or modpack server files.
- Place the
.jar file or unzipped files into the data folder.
-
Run Docker Container
docker compose up -d
Note: You must run this command inside mcsrv folder
-
Attach to the Container
docker attach mcsrv-mc-1
You are now in the Docker container.
-
Initial Server Configuration
- Follow the server or modpack guide for the initial setup. If no guide is available, common steps include:
- Run the server manually for the first time, wait until the world generates, and stop it with
stop.
-
Detach and Stop the Container
- Use
Ctrl + P, then Ctrl + Q to detach from the container.
- Run this command inside
mcsrv folder to stop the container:docker compose down
-
Finalize Docker Configuration
- Edit the
Dockerfile to uncomment the CMD line and ensure it points to your run.sh script.
- If necessary, modify the line to match the script provided by the modpack. (e.g,
startserver.sh, start.sh, etc.)
Usage
-
Start Server
docker compose up -d
Note: If you are running this command for the first time after installation, use docker compose up -d --build. Also, ensure you are executing the command inside the mcsrv folder.
-
Stop Server
docker attach mcsrv-mc-1
stop
docker compose down
-
Stop Server (Emergency)
docker compose down
Note: Use this command inside mcsrv folder if the server is unresponsive or crashes.
-
Access Server Console
docker attach mcsrv-mc-1
-
Exit Console
- Use
Ctrl + P, then Ctrl + Q.
Uninstallation
-
Remove Folder
rm -rf mcsrv
-
Remove Docker Container, Image, and Volume
docker container rm -f mcsrv-mc-1
docker image rm mcsrv-mc
docker volume rm mcsrv_data
Troubleshooting
For issues or questions, refer to:
Version: 1.0.21
Date: 2024-09-18
License: MIT License
Author: Filip Rokita
评论