Thanks to visit codestin.com
Credit goes to github.com

Skip to content

stuarthayhurst/minecraft-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minecraft Docker

  • Scripts and configs to run a Spigot Minecraft server in a Docker container
    • Uses Ping Shutdown to gracefully stop the server on container stop
  • This was written for my personal setup, your mileage may vary

Usage:

  • Run docker compose build to build the container
  • Run docker compose up to start the container
  • Run docker compose stop or docker compose down to stop the container
  • Run docker compose attach minecraft to attach to the server's command prompt
  • The container uses the unless-stopped restart policy

Volumes:

  • The volumes can be managed as a project, see Projects
  • Within the container, several mountpoints exist:
    • data/: Generic persistent data, designed for worlds and the server icon
      • Worlds and the icon use this by default, but it can be used for arbitrary data
    • config/: Configuration files for the server, see Dockerfile for the symlinks pointing here
    • plugins/: Plugins and their configs, comes with PingShutdown to handle container stops gracefully
    • logs/: Logs and crash reports for the server

Projects:

  • The persistent data (log, plugins, configs, etc) is stored in several volumes
    • These are grouped into a project
  • Use ./create-project.sh [NAME] to create the directory structure for a new project
  • Use --project-name [NAME] with the Docker commands to switch to a different project
  • Projects can be used to quickly swap to a different server configuration

Config:

  • compose.yaml defines several build arguments and environment variables
  • Build arguments:
    • JAVA_VERSION - The version of major Java to use in the container
    • SPIGOT_VERSION - The version of Minecraft to build Spigot for
    • EULA: [true (default) / false] - Accept / reject the EULA
    • USER_UID - The UID of the user inside the container, defaults to 1000
      • Will be used as the user ID for the volumes too
    • USER_GID - The GID of the user inside the container, defaults to 1000
      • Will be used as the group ID for the volumes too
  • Environment variables:
    • MINRAM - Minimum amount of RAM to allocate for the JVM, defaults to 2G
    • MAXRAM - Maximum amount of RAM to allocate for the JVM, defaults to 16G
    • SHUTDOWN_PORT: [1 - 65535] - The port to use for PingShutdown, defaults to 20563
      • PingShutdown's config must be changed to match, found in projects/[NAME]/plugins/PingShutdown/config.yml
    • WORLD_PATH - Path relative to the server to store the worlds in, defaults to data

Warning

SHUTDOWN_PORT should be internal to container, otherwise anyone can ping the port to restart the server

Backups:

  • Use BACKUP_NAME and VERSION in backup-config to configure the backup's name
  • Run ./backup.sh [DESTINATION] to backup projects/
    • If DESTINATION isn't specified or doesn't exist, the repository's directory will be used instead
  • Backups use tar and pbzip2

About

Scripts and configs to run a Spigot Minecraft server in a Docker container

Topics

Resources

License

Stars

Watchers

Forks

Contributors