Skip to content

Instantly share code, notes, and snippets.

@nosmall
Last active March 23, 2025 19:27
Show Gist options
  • Save nosmall/423fc91dbde057343f1ff6428868610e to your computer and use it in GitHub Desktop.
Save nosmall/423fc91dbde057343f1ff6428868610e to your computer and use it in GitHub Desktop.
Running a Minecraft Server in Docker
version: '3'
services:
minecraft:
container_name: minecraft
network_mode: bridge
image: 'itzg/minecraft-server'
ports:
- 25565:25565
environment:
OVERRIDE_SERVER_PROPERTIES: "TRUE"
EULA: "TRUE"
SEED: "6391130274229160289"
DIFFICULTY: "normal"
FORCE_GAMEMODE: "FALSE"
MODE: "survival"
ONLINE_MODE: "TRUE"
SERVER_NAME: "srv5.jiripocta.cz"
MOTD: "§l§cJirik§r a §l§cHonzik§r je §nVELKO-PANEM teto zeme"
OVERRIDE_ICON: "TRUE"
ICON: "https://screenshot.cz/5Y/5YWP7/kluci.png"
ENABLE_COMMAND_BLOCK: "FALSE"
ENABLE_RCON: "FALSE"
RCON_PASSWORD: "0a212f1d040bcf7fdd97ee99fgh"
ENABLE_QUERY: "FALSE"
SPAWN_PROTECTION: "256"
MAX_PLAYERS: "8"
PVP: "TRUE"
ALLOW_FLIGHT: "FALSE"
ENABLE_WHITELIST: "TRUE"
WHITELIST: |
JPCraftiCZ
AdamCraftic
OPS: |
JPCraftiCZ
AdamCraftic
tty: true
stdin_open: true
restart: unless-stopped
volumes:
- './data:/data'
- /etc/localtime:/etc/localtime:ro
- /etc/timezone:/etc/timezone:ro

Running a Minecraft Server in Docker

Source: https://waylonwalker.com/docker-minecraft-server/

# Start server
docker compose up -d

# Update server to latest version
docker-compose down
docker compose pull
docker-compose up --force-recreate --build -d
docker image prune -f

# Generate New World
cd ~/Docker/minecraftServer/data
docker-compose down
rm -rf {world/,logs/,*.properties}
docker compose pull
docker-compose up --force-recreate --build -d
docker image prune -f

# How To Reset the World on Your Minecraft Server
cd ~/Docker/minecraftServer/data
docker-compose down
# rm -rf {world/,logs/,*.txt,*.json,*.properties}
rm -rf {world/,logs/,*.properties}
# rm -rf backups/playerdata/ && cp -r world/playerdata/ backups/
# rm -rf {world/!(playerdata),logs/,*.txt,*.json,*.properties}
docker-compose up --force-recreate --build -d

# Open/Attach minecraft server Console
#NOTE: Press Ctrl-P, followed by Ctrl-Q, to detach from your connection.
docker attach minecraft
docker compose logs -f

# Game Rules
#(https://nodecraft.com/support/games/minecraft/using-gamerules-in-minecraft#h-list-of-gamerules-fc34423d4)
/whitelist off/on
/gamerule doImmediateRespawn true #Players respawn immediately without showing the death screen
/gamerule keepInventory true #Whether the player should keep items in their inventory after death
/gamerule logAdminCommands true #Whether the player should keep items in their inventory after death
/gamerule pvp true #Whether the player can fight with other players

# Game Commands
#(https://minecraft.fandom.com/wiki/Commands)
#(https://www.ign.com/wikis/minecraft/Console_Commands_and_Cheats_List#All_Console_Commands_and_Cheats_List)
/op @a #Grants All players operator status on the server.
/op playername #Grants playername operator status on the server.
/gamemode creative #Switch your server to Creative Mode
/gamemode survival #Switch your server to Survival Mode
/locate structure village #Find villages GPS
/tp [player] [x y z] #Teleport a player to a specific location
/experience add <player> <amount> #Give a player free experience points
/difficulty <level> #Change the difficulty of your game (Peaceful, Easy, Normal, or Hard)
/weather <type> #Change the weather
/time set night #Set night
/give <player> <item> [quantity] #Give a player free items
/summon <entity> [x y z] #Create a mob at the select location
/execute as @e[limit=16] run summon minecraft:zombie ~ ~ ~ #Spawn lot of zombie (https://www.digminecraft.com/mobs/index.php)

/give @s netherite_axe[minecraft:custom_name='{"text":"MEGA SEKACKA"}',enchantments={levels:{sharpness:255,sweeping_edge:255,looting:255,fire_aspect:255,mending:255,unbreaking:255}}] 3

/give @p crossbow[custom_name='{"text":"MEGA KUSE"}',enchantments={levels:{'multishot':255,'quick_charge':255,'unbreaking':255,'mending':255}}] 3

/give @p netherite_sword[custom_name='{"text":"MEGA MECIK"}',enchantments={levels:{'sweeping_edge':255,'sharpness':255,'knockback':255,'fire_aspect':255,'looting':255,'unbreaking':255,'mending':255}}] 3

# mods forge
https://github.com/NikitaCartes/EasyAuth
https://www.curseforge.com/minecraft/mc-mods/easywhitelist

# restore backup
rclone copy jp:/srv5/Docker-incrementals/20250116.062501/minecraftServer /root/Docker/minecraftServer -v --tpslimit 7 -c --checkers=20 --transfers=5 --drive-chunk-size 256M --fast-list
@nosmall
Copy link
Author

nosmall commented Jul 17, 2023

/locate structure village #Find villages GPS

1.21 Java Edition - https://beebom.com/best-minecraft-1-21-seeds/
Seed Code: -7833842402223417925
Spawn Biome: Forest
Coordinates for the first trial chamber south from spawn: X: 7 Z: 345
Coordinates for the first village south from spawn: X: 64 Z: 656
Coordinates for the second trial chamber south from spawn: X: 7 Z: 855
Coordinates for the third trial chamber south from spawn: X: -9 Z: 1193

@nosmall
Copy link
Author

nosmall commented Feb 11, 2025

/kill @e[type=zombie]
/kill @e[type=skeleton]
/kill @e[type=creeper]
/kill @e[type=spider]
/kill @e[type=cave_spider]
/kill @e[type=witch]
/kill @e[type=enderman]
/kill @e[type=slime]

... a další nepřátelské moby podle potřeby

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment