Skip to content

Instantly share code, notes, and snippets.

@nosmall
Last active June 13, 2024 15:22
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: "1738801"
DIFFICULTY: "normal"
FORCE_GAMEMODE: "FALSE"
MODE: "survival"
ONLINE_MODE: "FALSE"
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: "0a212f1d040bcf7fdd97ee99"
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

# 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 @p netherite_sword{Enchantments:[{id:sharpness,lvl:100000000},{id:sweeping,lvl:100}],Unbreakable:1,HideFlags:5}
/give @p crossbow{Enchantments:[{id:mending,lvl:1},{id:multishot,lvl:1},{id:piercing,lvl:4},{id:quick_charge,lvl:5},{id:unbreaking,lvl:3}],HideFlags:1}
@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

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