게임/마인크래프트

빠르게 서버를 구축하기 위한 Docker Compose 템플릿 공유

Lou Park 2023. 7. 23. 03:46

version: "3.4"

services:
  mc:
    image: itzg/minecraft-server
    container_name: mc
    tty: true
    stdin_open: true
    ports:
      - 25565:25565
      - 25575:25575
    environment:
      # server type
      TYPE: FORGE
      FORGE_VERSION: "47.1.21"
      VERSION: "1.20.1"
      # server.properties
      SERVER_NAME: "Server Name"
      MOTD: "Your Server's MOTD"
      EULA: TRUE
      GAMEMODE: SURVIVAL
      DIFFICULTY: EASY
      VIEW_DISTANCE: 10
      SIMULATION_DISTANCE: 4
      MAX_PLAYERS: 32
      NETWORK_COMPRESSION_THRESHOLD: 512 # slow cpu=512, slow internet = 64
      RCON_CMDS_STARTUP: |-
        whitelist on
      # etc
      MEMORY: "6G"
      MAX_MEMORY: "24G"
      JVM_OPTS: "--add-modules=jdk.incubator.vector -XX:+UseG1GC -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=200 -XX:+UnlockExperimentalVMOptions -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -XX:G1HeapWastePercent=5 -XX:G1MixedGCCountTarget=4 -XX:InitiatingHeapOccupancyPercent=15 -XX:G1MixedGCLiveThresholdPercent=90 -XX:G1RSetUpdatingPauseTimePercent=5 -XX:SurvivorRatio=32 -XX:+PerfDisableSharedMem -XX:MaxTenuringThreshold=1 -Dusing.aikars.flags=https://mcflags.emc.gs -Daikars.new.flags=true -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=50 -XX:G1HeapRegionSize=16M -XX:G1ReservePercent=15"
    volumes:
      - ./data:/data
  backup:
    image: itzg/mc-backup
    container_name: backup
    environment:
      BACKUP_INTERVAL: "3h"
      RCON_RETRY_INTERVAL: "10m"
      PAUSE_IF_NO_PLAYERS: TRUE
      PLAYERS_ONLINE_CHECK_INTERVAL: "10m"
      PRUNE_BACKUPS_DAYS: 1
    volumes:
      - ./data:/data:ro
      - ./backups:/backups
    network_mode: "service:mc"

 

# rcon 열기
sudo docker exec -it mc rcon-cli

 

# Log 보기
sudo docker logs mc -f

 

# 재시작
sudo docker compose down
sudo docker compose up -d

 

Document https://docker-minecraft-server.readthedocs.io/en/latest/