Welcome! This project provides a straightforward way to set up a customized Minecraft server using Docker and Docker Compose. By following this guide, you can create a fun and secure environment for you and your friends to enjoy Minecraft together.
- Introduction
- Features
- Prerequisites
- Installation
- Usage
- How to Connect to the Server
- Server Administration
- Data Persistence
- Troubleshooting
- Acknowledgments
This project leverages Docker to run a Minecraft server with specific configurations tailored for a private group. Using Docker Compose ensures that the server setup is reproducible, manageable, and easy to deploy.
- Minecraft Version: 1.20.4 (VANILLA)
- Game Mode: Survival
- Difficulty: Easy
- Custom World Seed:
your-custom-seed
- Whitelist Enabled: Only specified players can join
- Operators (Admins): Customizable list
- Memory Allocation: 8G
- Data Persistence: World data stored in a Docker volume
- Custom MOTD: "Welcome to Our Minecraft Server!"
- Operating System: Fedora (or any Linux distribution)
- Docker: Installed and running
- Docker Compose: Installed
Follow the steps below to set up the Minecraft server on your Fedora system.
Open a terminal and run:
sudo dnf update -y && sudo dnf upgrade -y
Install Docker and Docker Compose:
sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose
Enable and start the Docker service:
sudo systemctl enable docker
sudo systemctl start docker
Verify Docker is running:
docker --version
docker compose version
Create a directory for the server and navigate into it:
mkdir minecraft-server
cd minecraft-server
Create a docker-compose.yaml
file with the following content:
version: "3.8"
services:
minecraft:
image: itzg/minecraft-server
container_name: minecraft_server
ports:
- "25565:25565" # Map host port 25565 to container port 25565
environment:
EULA: "TRUE"
TYPE: "VANILLA"
VERSION: "1.20.4"
LEVEL_TYPE: "DEFAULT"
GAMEMODE: "survival"
DIFFICULTY: "easy"
MAX_PLAYERS: "20"
SEED: "your-custom-seed"
MOTD: "Welcome to Our Minecraft Server!"
OPS: "admin1,admin2"
WHITELIST: "player1,player2,player3"
OVERRIDE_SERVER_PROPERTIES: "TRUE"
MAX_WORLD_SIZE: "100000"
FORCE_GAMEMODE: "TRUE"
MAX_BUILD_HEIGHT: "512"
SPAWN_PROTECTION: "16"
VIEW_DISTANCE: "16"
PVP: "TRUE"
MEMORY: "8G"
ENABLE_WHITELIST: "TRUE"
ENFORCE_WHITELIST: "TRUE"
ENABLE_ROLLING_LOGS: "TRUE"
volumes:
- minecraft_data:/data # Named volume for data persistence
volumes:
minecraft_data:
driver: local
Alternatively, you can create the file using a single command:
cat <<EOF > docker-compose.yaml
[PASTE THE ABOVE YAML CONTENT HERE]
EOF
Run the following command to start the server in detached mode:
docker compose up -d
Verify that the server is running:
docker ps
You should see a container named minecraft_server
in the list.
To monitor the server logs in real-time:
docker logs minecraft_server -f
Press Ctrl+C
to exit the log view.
If you make changes to the docker-compose.yaml
file or need to restart the server:
docker restart minecraft_server
To stop the server:
docker compose down
-
Ensure You're Whitelisted
Make sure your Minecraft username is included in the whitelist. The current whitelist includes:
- player1
- player2
- player3
If your username is not listed, contact one of the server operators to be added.
-
Launch Minecraft
Open your Minecraft client. Ensure you're using version 1.20.4 to match the server.
-
Add the Server
- Click on
Multiplayer
. - Click on
Add Server
. - Enter the following details:
- Server Name: Custom Minecraft Server
- Server Address:
<Server IP Address>:25565
- Replace
<Server IP Address>
with the public IP address or hostname of the server.
- Replace
- Click
Done
.
- Click on
-
Connect to the Server
- Select the server from your list.
- Click
Join Server
.
- Local Network: If you're on the same network as the server, use the server's local IP address.
- Remote Connection: If connecting over the internet, ensure that the server's firewall allows incoming connections on port
25565
, and that port forwarding is set up correctly on the router.
Operators have elevated permissions and can perform administrative tasks.
-
Start the Server:
docker compose up -d
-
Stop the Server:
docker compose down
-
Restart the Server:
docker restart minecraft_server
While you cannot interact with the Minecraft server console directly via Docker, you can execute commands within the container:
docker exec -it minecraft_server rcon-cli
Note: You need to enable rcon
in the server settings to use rcon-cli
. Alternatively, you can manage the server using in-game commands if you have operator privileges.
-
Edit
docker-compose.yaml
Modify any necessary environment variables under the
environment
section. -
Apply Changes
Restart the server to apply new configurations:
docker compose down docker compose up -d
As an operator, you can manage the whitelist and other players directly from within the game.
-
Add a Player to Whitelist:
/whitelist add <username>
-
Remove a Player from Whitelist:
/whitelist remove <username>
-
Add an Operator:
/op <username>
-
Remove an Operator:
/deop <username>
It's important to regularly back up your world data.
-
Create a Backup
docker run --rm -v minecraft_data:/data -v $(pwd):/backup ubuntu tar cvf /backup/minecraft_backup.tar /data
This command will create a
minecraft_backup.tar
file in your current directory. -
Restore from Backup
To restore from a backup, stop the server, remove the existing volume, create a new volume, and extract the backup into it.
docker compose down docker volume rm minecraft-server_minecraft_data docker volume create minecraft-server_minecraft_data docker run --rm -v minecraft-server_minecraft_data:/data -v $(pwd):/backup ubuntu tar xvf /backup/minecraft_backup.tar -C / docker compose up -d
The server uses a Docker volume named minecraft_data
to store world data and configurations. This ensures that your game progress is preserved across server restarts and Docker image updates.
-
Server Fails to Start
-
Check the logs for error messages:
docker logs minecraft_server
-
Ensure that no other application is using port
25565
.
-
-
Cannot Connect to the Server
- Verify the server is running and listening on the correct port.
- Ensure your client is running Minecraft version 1.20.4.
- Check firewall and router settings to ensure the server is accessible.
-
Whitelist Issues
- Make sure your username is correctly spelled in the whitelist.
- Contact an operator to verify your whitelist status.
If you need to remove unused Docker resources:
docker system prune --all --force
Warning: This command will remove all unused containers, networks, images, and optionally, volumes. Use with caution.
- Docker Image: itzg/minecraft-server
- Minecraft: Official Website
- Docker: Docker Documentation
- Fedora: Fedora Project
This server setup is intended for private use among friends or small communities. Please ensure you have the proper permissions to host and manage a Minecraft server and adhere to Minecraft's End User License Agreement.