docs: mkdocs cleanup and caught up with latest README changes (#2155)

This commit is contained in:
Geoff Bourne 2023-05-28 16:14:57 -05:00 committed by GitHub
parent f1e5e48950
commit 1932f0cfd4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 483 additions and 420 deletions

View file

@ -1,3 +1,7 @@
---
title: Sending commands
---
[RCON](http://wiki.vg/RCON) is enabled by default, so you can `exec` into the container to
access the Minecraft server console:

View file

@ -0,0 +1,71 @@
# Auto-execute RCON commands
RCON commands can be configured to execute when the server starts, a client connects, or a client disconnects.
!!! note
When declaring several commands within a compose file environment variable, it's easiest to use YAML's `|-` [block style indicator](https://yaml-multiline.info/).
**On Server Start:**
``` yaml
RCON_CMDS_STARTUP: |-
gamerule doFireTick false
pregen start 200
```
**On Client Connection:**
``` yaml
RCON_CMDS_ON_CONNECT: |-
team join New @a[team=]
```
**Note:**
* On client connect we only know there was a connection, and not who connected. RCON commands will need to be used for that.
**On Client Disconnect:**
``` yaml
RCON_CMDS_ON_DISCONNECT: |-
gamerule doFireTick true
```
**On First Client Connect**
``` yaml
RCON_CMDS_FIRST_CONNECT: |-
pregen stop
```
**On Last Client Disconnect**
``` yaml
RCON_CMDS_LAST_DISCONNECT: |-
kill @e[type=minecraft:boat]
pregen start 200
```
**Example of rules for new players**
Uses team NEW and team OLD to track players on the server. So move player with no team to NEW, run a command, move them to team OLD.
[Reference Article](https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/2213523-detect-players-first-join)
``` yaml
RCON_CMDS_STARTUP: |-
/pregen start 200
/gamerule doFireTick false
/team add New
/team add Old
RCON_CMDS_ON_CONNECT: |-
/team join New @a[team=]
/give @a[team=New] birch_boat
/team join Old @a[team=New]
RCON_CMDS_FIRST_CONNECT: |-
/pregen stop
RCON_CMDS_LAST_DISCONNECT: |-
/kill @e[type=minecraft:boat]
/pregen start 200
```

View file

@ -0,0 +1,142 @@
---
title: Modifying config files
---
## Replacing variables inside configs
Sometimes you have mods or plugins that require configuration information that is only available at runtime.
For example if you need to configure a plugin to connect to a database,
you don't want to include this information in your Git repository or Docker image.
Or maybe you have some runtime information like the server name that needs to be set
in your config files after the container starts.
For those cases there is the option to replace defined variables inside your configs
with environment variables defined at container runtime.
When the environment variable `REPLACE_ENV_IN_PLACE` is set to `true` (the default), the startup script will go through all files inside the container's `/data` path and replace variables that match the container's environment variables. Variables can instead (or in addition to) be replaced in files sync'ed from `/plugins`, `/mods`, and `/config` by setting `REPLACE_ENV_DURING_SYNC` to `true` (defaults to `false`).
Variables that you want to replace need to be declared inside curly brackets and prefixed with a dollar sign, such as `${CFG_YOUR_VARIABLE}`, which is same as many scripting languages.
You can also change `REPLACE_ENV_VARIABLE_PREFIX`, which defaults to "CFG_", to limit which environment variables are allowed to be used. For example, with "CFG_" as the prefix, the variable `${CFG_DB_HOST}` would be subsituted, but not `${DB_HOST}`.
If you want to use a file's content for value, such as when using secrets mounted as files, declare the placeholder named like normal in the file and declare an environment variable named the same but with the suffix `_FILE`.
For example, a `my.cnf` file could contain:
```
[client]
password = ${CFG_DB_PASSWORD}
```
...a secret declared in the compose file with:
```yaml
secrets:
db_password:
external: true
```
...and finally the environment variable would be named with a `_FILE` suffix and point to the mounted secret:
```yaml
environment:
CFG_DB_PASSWORD_FILE: /run/secrets/db_password
```
Variables will be replaced in files with the following extensions:
`.yml`, `.yaml`, `.txt`, `.cfg`, `.conf`, `.properties`.
Specific files can be excluded by listing their name (without path) in the variable `REPLACE_ENV_VARIABLES_EXCLUDES`.
Paths can be excluded by listing them in the variable `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. Path
excludes are recursive. Here is an example:
```
REPLACE_ENV_VARIABLES_EXCLUDE_PATHS="/data/plugins/Essentials/userdata /data/plugins/MyPlugin"
```
Here is a full example where we want to replace values inside a `database.yml`.
```yml
---
database:
host: ${CFG_DB_HOST}
name: ${CFG_DB_NAME}
password: ${CFG_DB_PASSWORD}
```
This is how your `docker-compose.yml` file could look like:
```yml
version: "3.8"
# Other docker-compose examples in /examples
services:
minecraft:
image: itzg/minecraft-server
ports:
- "25565:25565"
volumes:
- "mc:/data"
environment:
EULA: "TRUE"
ENABLE_RCON: "true"
RCON_PASSWORD: "testing"
RCON_PORT: 28016
# enable env variable replacement
REPLACE_ENV_VARIABLES: "TRUE"
# define an optional prefix for your env variables you want to replace
ENV_VARIABLE_PREFIX: "CFG_"
# and here are the actual variables
CFG_DB_HOST: "http://localhost:3306"
CFG_DB_NAME: "minecraft"
CFG_DB_PASSWORD_FILE: "/run/secrets/db_password"
volumes:
mc:
rcon:
secrets:
db_password:
file: ./db_password
```
## Patching existing files
JSON path based patches can be applied to one or more existing files by setting the variable `PATCH_DEFINITIONS` to the path of a directory that contains one or more [patch definition json files](https://github.com/itzg/mc-image-helper#patchdefinition) or a [patch set json file](https://github.com/itzg/mc-image-helper#patchset).
Variable placeholders in the patch values can be restricted by setting `REPLACE_ENV_VARIABLE_PREFIX`, which defaults to "CFG_".
The following example shows a patch-set file were various fields in the `paper.yaml` configuration file can be modified and added:
```json
{
"patches": [
{
"file": "/data/paper.yml",
"ops": [
{
"$set": {
"path": "$.verbose",
"value": true
}
},
{
"$set": {
"path": "$.settings['velocity-support'].enabled",
"value": "${CFG_VELOCITY_ENABLED}",
"value-type": "bool"
}
},
{
"$put": {
"path": "$.settings",
"key": "my-test-setting",
"value": "testing"
}
}
]
}
]
}
```
> **NOTES:** Only JSON and Yaml files can be patched at this time. TOML support is planned to be added next. Removal of comments and other cosmetic changes will occur when patched files are processed.

View file

@ -0,0 +1,77 @@
# JVM Options
## Memory Limit
By default, the image declares an initial and maximum Java memory-heap limit of 1 GB. There are several ways to adjust the memory settings:
- `MEMORY`: "1G" by default, can be used to adjust both initial (`Xms`) and max (`Xmx`) memory heap settings of the JVM
- `INIT_MEMORY`: independently sets the initial heap size
- `MAX_MEMORY`: independently sets the max heap size
The values of all three are passed directly to the JVM and support format/units as `<size>[g|G|m|M|k|K]`. For example:
-e MEMORY=2G
To let the JVM calculate the heap size from the container declared memory limit, unset `MEMORY` with an empty value, such as `-e MEMORY=""`. By default, the JVM will use 25% of the container memory limit as the heap limit; however, as an example the following would tell the JVM to use 75% of the container limit of 2GB of memory:
-e MEMORY="" -e JVM_XX_OPTS="-XX:MaxRAMPercentage=75" -m 2000M
!!! important
The settings above only set the Java **heap** limits. Memory resource requests and limits on the overall container should also account for non-heap memory usage. An extra 25% is [a general best practice](https://dzone.com/articles/best-practices-java-memory-arguments-for-container).
## Extra JVM Options
General JVM options can be passed to the Minecraft Server invocation by passing a `JVM_OPTS`
environment variable. The JVM requires `-XX` options to precede `-X` options, so those can be declared in `JVM_XX_OPTS`. Both variables are space-delimited, raw JVM arguments.
```
docker run ... -e JVM_OPTS="-someJVMOption someJVMOptionValue" ...
```
**NOTE** When declaring `JVM_OPTS` in a compose file's `environment` section with list syntax, **do not** include the quotes:
```yaml
environment:
- EULA=true
- JVM_OPTS=-someJVMOption someJVMOptionValue
```
Using object syntax is recommended and more intuitive:
```yaml
environment:
EULA: "true"
JVM_OPTS: "-someJVMOption someJVMOptionValue"
# or
# JVM_OPTS: -someJVMOption someJVMOptionValue
```
As a shorthand for passing several system properties as `-D` arguments, you can instead pass a comma separated list of `name=value` or `name:value` pairs with `JVM_DD_OPTS`. (The colon syntax is provided for management platforms like Plesk that don't allow `=` inside a value.)
For example, instead of passing
```yaml
JVM_OPTS: -Dfml.queryResult=confirm -Dname=value
```
you can use
```yaml
JVM_DD_OPTS: fml.queryResult=confirm,name=value
```
## Enable Remote JMX for Profiling
To enable remote JMX, such as for profiling with VisualVM or JMC, add the environment variable `ENABLE_JMX=true`, set `JMX_HOST` to the IP/host running the Docker container, and add a port forwarding of TCP port 7091, such as:
```
-e ENABLE_JMX=true -e JMX_HOST=$HOSTNAME -p 7091:7091
```
## Enable Aikar's Flags
[Aikar has done some research](https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/) into finding the optimal JVM flags for GC tuning, which becomes more important as more users are connected concurrently. The set of flags documented there can be added using
-e USE_AIKAR_FLAGS=true
When `MEMORY` is greater than or equal to 12G, then the Aikar flags will be adjusted according to the article.

View file

@ -1,143 +1,5 @@
### Replacing variables inside configs
Sometimes you have mods or plugins that require configuration information that is only available at runtime.
For example if you need to configure a plugin to connect to a database,
you don't want to include this information in your Git repository or Docker image.
Or maybe you have some runtime information like the server name that needs to be set
in your config files after the container starts.
For those cases there is the option to replace defined variables inside your configs
with environment variables defined at container runtime.
When the environment variable `REPLACE_ENV_IN_PLACE` is set to `true` (the default), the startup script will go through all files inside the container's `/data` path and replace variables that match the container's environment variables. Variables can instead (or in addition to) be replaced in files sync'ed from `/plugins`, `/mods`, and `/config` by setting `REPLACE_ENV_DURING_SYNC` to `true` (defaults to `false`).
Variables that you want to replace need to be declared inside curly brackets and prefixed with a dollar sign, such as `${CFG_YOUR_VARIABLE}`, which is same as many scripting languages.
You can also change `REPLACE_ENV_VARIABLE_PREFIX`, which defaults to "CFG_", to limit which environment variables are allowed to be used. For example, with "CFG_" as the prefix, the variable `${CFG_DB_HOST}` would be subsituted, but not `${DB_HOST}`.
If you want to use a file's content for value, such as when using secrets mounted as files, declare the placeholder named like normal in the file and declare an environment variable named the same but with the suffix `_FILE`.
For example, a `my.cnf` file could contain:
```
[client]
password = ${CFG_DB_PASSWORD}
```
...a secret declared in the compose file with:
```yaml
secrets:
db_password:
external: true
```
...and finally the environment variable would be named with a `_FILE` suffix and point to the mounted secret:
```yaml
environment:
CFG_DB_PASSWORD_FILE: /run/secrets/db_password
```
Variables will be replaced in files with the following extensions:
`.yml`, `.yaml`, `.txt`, `.cfg`, `.conf`, `.properties`.
Specific files can be excluded by listing their name (without path) in the variable `REPLACE_ENV_VARIABLES_EXCLUDES`.
Paths can be excluded by listing them in the variable `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. Path
excludes are recursive. Here is an example:
```
REPLACE_ENV_VARIABLES_EXCLUDE_PATHS="/data/plugins/Essentials/userdata /data/plugins/MyPlugin"
```
Here is a full example where we want to replace values inside a `database.yml`.
```yml
---
database:
host: ${CFG_DB_HOST}
name: ${CFG_DB_NAME}
password: ${CFG_DB_PASSWORD}
```
This is how your `docker-compose.yml` file could look like:
```yml
version: "3.8"
# Other docker-compose examples in /examples
services:
minecraft:
image: itzg/minecraft-server
ports:
- "25565:25565"
volumes:
- "mc:/data"
environment:
EULA: "TRUE"
ENABLE_RCON: "true"
RCON_PASSWORD: "testing"
RCON_PORT: 28016
# enable env variable replacement
REPLACE_ENV_VARIABLES: "TRUE"
# define an optional prefix for your env variables you want to replace
ENV_VARIABLE_PREFIX: "CFG_"
# and here are the actual variables
CFG_DB_HOST: "http://localhost:3306"
CFG_DB_NAME: "minecraft"
CFG_DB_PASSWORD_FILE: "/run/secrets/db_password"
volumes:
mc:
rcon:
secrets:
db_password:
file: ./db_password
```
### Patching existing files
JSON path based patches can be applied to one or more existing files by setting the variable `PATCH_DEFINITIONS` to the path of a directory that contains one or more [patch definition json files](https://github.com/itzg/mc-image-helper#patchdefinition) or a [patch set json file](https://github.com/itzg/mc-image-helper#patchset).
Variable placeholders in the patch values can be restricted by setting `REPLACE_ENV_VARIABLE_PREFIX`, which defaults to "CFG_".
The following example shows a patch-set file were various fields in the `paper.yaml` configuration file can be modified and added:
```json
{
"patches": [
{
"file": "/data/paper.yml",
"ops": [
{
"$set": {
"path": "$.verbose",
"value": true
}
},
{
"$set": {
"path": "$.settings['velocity-support'].enabled",
"value": "${CFG_VELOCITY_ENABLED}",
"value-type": "bool"
}
},
{
"$put": {
"path": "$.settings",
"key": "my-test-setting",
"value": "testing"
}
}
]
}
]
}
```
> **NOTES:** Only JSON and Yaml files can be patched at this time. TOML support is planned to be added next. Removal of comments and other cosmetic changes will occur when patched files are processed.
### Running with a custom server JAR
## Running with a custom server JAR
If you would like to run a custom server JAR, set `-e TYPE=CUSTOM` and pass the custom server
JAR via `CUSTOM_SERVER`. It can either be a URL or a container path to an existing JAR file.
@ -146,7 +8,7 @@ If it is a URL, it will only be downloaded into the `/data` directory if it wasn
such, if you need to upgrade or re-download the JAR, then you will need to stop the container,
remove the file from the container's `/data` directory, and start again.
### Force re-download of the server file
## Force re-download of the server file
For VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, CURSEFORGE, SPONGEVANILLA server types, set
`$FORCE_REDOWNLOAD` to some value (e.g. 'true) to force a re-download of the server file for
@ -160,7 +22,7 @@ docker run -d -v /path/on/host:/data \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
```
### Running as alternate user/group ID
## Running as alternate user/group ID
By default, the container will switch to user ID 1000 and group ID 1000;
however, you can override those values by setting `UID` and/or `GID` as environmental entries, during the `docker run` command.
@ -171,72 +33,13 @@ however, you can override those values by setting `UID` and/or `GID` as environm
The container will also skip user switching if the `--user`/`-u` argument
is passed to `docker run`.
### Memory Limit
By default, the image declares an initial and maximum Java memory-heap limit of 1 GB. There are several ways to adjust the memory settings:
- `MEMORY`: "1G" by default, can be used to adjust both initial (`Xms`) and max (`Xmx`) memory heap settings of the JVM
- `INIT_MEMORY`: independently sets the initial heap size
- `MAX_MEMORY`: independently sets the max heap size
The values of all three are passed directly to the JVM and support format/units as `<size>[g|G|m|M|k|K]`. For example:
-e MEMORY=2G
To let the JVM calculate the heap size from the container declared memory limit, unset `MEMORY` with an empty value, such as `-e MEMORY=""`. By default, the JVM will use 25% of the container memory limit as the heap limit; however, as an example the following would tell the JVM to use 75% of the container limit of 2GB of memory:
-e MEMORY="" -e JVM_XX_OPTS="-XX:MaxRAMPercentage=75" -m 2000M
> The settings above only set the Java **heap** limits. Memory resource requests and limits on the overall container should also account for non-heap memory usage. An extra 25% is [a general best practice](https://dzone.com/articles/best-practices-java-memory-arguments-for-container).
### JVM Options
General JVM options can be passed to the Minecraft Server invocation by passing a `JVM_OPTS`
environment variable. The JVM requires `-XX` options to precede `-X` options, so those can be declared in `JVM_XX_OPTS`. Both variables are space-delimited, raw JVM arguments.
```
docker run ... -e JVM_OPTS="-someJVMOption someJVMOptionValue" ...
```
**NOTE** When declaring `JVM_OPTS` in a compose file's `environment` section with list syntax, **do not** include the quotes:
```yaml
environment:
- EULA=true
- JVM_OPTS=-someJVMOption someJVMOptionValue
```
Using object syntax is recommended and more intuitive:
```yaml
environment:
EULA: "true"
JVM_OPTS: "-someJVMOption someJVMOptionValue"
# or
# JVM_OPTS: -someJVMOption someJVMOptionValue
```
As a shorthand for passing several system properties as `-D` arguments, you can instead pass a comma separated list of `name=value` or `name:value` pairs with `JVM_DD_OPTS`. (The colon syntax is provided for management platforms like Plesk that don't allow `=` inside a value.)
For example, instead of passing
```yaml
JVM_OPTS: -Dfml.queryResult=confirm -Dname=value
```
you can use
```yaml
JVM_DD_OPTS: fml.queryResult=confirm,name=value
```
### Extra Arguments
## Extra Arguments
Arguments that would usually be passed to the jar file (those which are written after the filename) can be passed via the `EXTRA_ARGS` environment variable.
See [Custom worlds directory path](../misc/world-data.md#custom-worlds-directory-path) for an example.
### Interactive and Color Console
## Interactive and Color Console
If you would like to `docker attach` to the Minecraft server console with color and interactive capabilities, then add
@ -254,13 +57,13 @@ If you would like to `docker attach` to the Minecraft server console with color
>
> This feature is incompatible with Autopause and cannot be set when `ENABLE_AUTOPAUSE=true`.
### Server Shutdown Options
## Server Shutdown Options
To allow time for players to finish what they're doing during a graceful server shutdown, set `STOP_SERVER_ANNOUNCE_DELAY` to a number of seconds to delay after an announcement is posted by the server.
> **NOTE** be sure to adjust Docker's shutdown timeout accordingly, such as using [the -t option on docker-compose down](https://docs.docker.com/compose/reference/down/).
### OpenJ9 Specific Options
## OpenJ9 Specific Options
The openj9 image tags include specific variables to simplify configuration:
@ -269,7 +72,7 @@ The openj9 image tags include specific variables to simplify configuration:
- `-e TUNE_NURSERY_SIZES=TRUE` : configures nursery sizes where the initial size is 50%
of the `MAX_MEMORY` and the max size is 80%.
### Enabling rolling logs
## Enabling rolling logs
By default the vanilla log file will grow without limit. The logger can be reconfigured to use a rolling log files strategy by using:
@ -279,7 +82,7 @@ By default the vanilla log file will grow without limit. The logger can be recon
> **NOTE** this will interfere with interactive/color consoles [as described in the section above](#interactive-and-color-console)
### Timezone Configuration
## Timezone Configuration
You can configure the timezone to match yours by setting the `TZ` environment variable:
@ -297,23 +100,7 @@ such as:
docker run -d -it -v /etc/timezone:/etc/timezone:ro -p 25565:25565 --name mc itzg/minecraft-server
### Enable Remote JMX for Profiling
To enable remote JMX, such as for profiling with VisualVM or JMC, add the environment variable `ENABLE_JMX=true`, set `JMX_HOST` to the IP/host running the Docker container, and add a port forwarding of TCP port 7091, such as:
```
-e ENABLE_JMX=true -e JMX_HOST=$HOSTNAME -p 7091:7091
```
### Enable Aikar's Flags
[Aikar has done some research](https://aikar.co/2018/07/02/tuning-the-jvm-g1gc-garbage-collector-flags-for-minecraft/) into finding the optimal JVM flags for GC tuning, which becomes more important as more users are connected concurrently. The set of flags documented there can be added using
-e USE_AIKAR_FLAGS=true
When `MEMORY` is greater than or equal to 12G, then the Aikar flags will be adjusted according to the article.
### HTTP Proxy
## HTTP Proxy
You may configure the use of an HTTP/HTTPS proxy by passing the proxy's URL via the `PROXY`
environment variable. In [the example compose file](https://github.com/itzg/docker-minecraft-server/blob/master/examples/docker-compose-proxied.yml) it references
@ -321,24 +108,24 @@ a companion squid proxy by setting the equivalent of
-e PROXY=proxy:3128
### Using "noconsole" option
## Using "noconsole" option
Some older versions (pre-1.14) of Spigot required `--noconsole` to be passed when detaching stdin, which can be done by setting `-e CONSOLE=FALSE`.
### Explicitly disable GUI
## Explicitly disable GUI
Some older servers get confused and think that the GUI interface is enabled. You can explicitly
disable that by passing `-e GUI=FALSE`.
### Stop Duration
## Stop Duration
When the container is signalled to stop, the Minecraft process wrapper will attempt to send a "stop" command via RCON or console and waits for the process to gracefully finish. By default it waits 60 seconds, but that duration can be configured by setting the environment variable `STOP_DURATION` to the number of seconds.
### Setup only
## Setup only
If you are using a host-attached data directory, then you can have the image setup the Minecraft server files and stop prior to launching the server process by setting `SETUP_ONLY` to `true`.
### Enable Flare Flags
## Enable Flare Flags
To enable the JVM flags required to fully support the [Flare profiling suite](https://blog.airplane.gg/flare), set the following variable:
@ -346,7 +133,7 @@ To enable the JVM flags required to fully support the [Flare profiling suite](ht
Flare is built-in to Pufferfish/Purpur, and is available in [plugin form](https://github.com/TECHNOVE/FlarePlugin) for other server types.
### Enable support for optimized SIMD operations
## Enable support for optimized SIMD operations
To enable support for optimized SIMD operations, the JVM flag can be set with the following variable:
@ -354,7 +141,7 @@ To enable support for optimized SIMD operations, the JVM flag can be set with th
SIMD optimized operations are supported by Pufferfish and Purpur.
### Enable timestamps in init logs
## Enable timestamps in init logs
Before the container starts the Minecraft Server its output is prefixed with `[init]`, such as
@ -367,74 +154,3 @@ To also include the timestamp with each log, set `LOG_TIMESTAMP` to "true". The
```
[init] 2022-02-05 16:58:33+00:00 Starting the Minecraft server...
```
### Auto-execute RCON commands
RCON commands can be configured to execute when the server starts, a client connects, or a client disconnects.
!!! note
When declaring several commands within a compose file environment variable, it's easiest to use YAML's `|-` [block style indicator](https://yaml-multiline.info/).
**On Server Start:**
``` yaml
RCON_CMDS_STARTUP: |-
gamerule doFireTick false
pregen start 200
```
**On Client Connection:**
``` yaml
RCON_CMDS_ON_CONNECT: |-
team join New @a[team=]
```
**Note:**
* On client connect we only know there was a connection, and not who connected. RCON commands will need to be used for that.
**On Client Disconnect:**
``` yaml
RCON_CMDS_ON_DISCONNECT: |-
gamerule doFireTick true
```
**On First Client Connect**
``` yaml
RCON_CMDS_FIRST_CONNECT: |-
pregen stop
```
**On Last Client Disconnect**
``` yaml
RCON_CMDS_LAST_DISCONNECT: |-
kill @e[type=minecraft:boat]
pregen start 200
```
**Example of rules for new players**
Uses team NEW and team OLD to track players on the server. So move player with no team to NEW, run a command, move them to team OLD.
[Reference Article](https://www.minecraftforum.net/forums/minecraft-java-edition/redstone-discussion-and/2213523-detect-players-first-join)
``` yaml
RCON_CMDS_STARTUP: |-
/pregen start 200
/gamerule doFireTick false
/team add New
/team add Old
RCON_CMDS_ON_CONNECT: |-
/team join New @a[team=]
/give @a[team=New] birch_boat
/team join Old @a[team=New]
RCON_CMDS_FIRST_CONNECT: |-
/pregen stop
RCON_CMDS_LAST_DISCONNECT: |-
/kill @e[type=minecraft:boat]
/pregen start 200
```

View file

@ -1,3 +1,6 @@
---
title: Intro
---
[![Docker Pulls](https://img.shields.io/docker/pulls/itzg/minecraft-server.svg)](https://hub.docker.com/r/itzg/minecraft-server/)
[![Docker Stars](https://img.shields.io/docker/stars/itzg/minecraft-server.svg?maxAge=2592000)](https://hub.docker.com/r/itzg/minecraft-server/)
[![GitHub Issues](https://img.shields.io/github/issues-raw/itzg/docker-minecraft-server.svg)](https://github.com/itzg/docker-minecraft-server/issues)

View file

@ -0,0 +1,16 @@
# Site documentation
The documentation for this image/repository is written in markdown and built by [MkDocs](https://www.mkdocs.org/) into a documentation website hosted at [Read the Docs](https://readthedocs.org/). [Here is general information about writing MkDocs markdown](https://www.mkdocs.org/user-guide/writing-your-docs/) and [specifics for the Material theme used](https://squidfunk.github.io/mkdocs-material/reference/).
!!! note
The README.md rarely needs to be modified and only serves as a brief introduction to the project.
The documentation source is maintained in the [docs](https://github.com/itzg/docker-minecraft-server/tree/master/docs) folder and is organized into sections by directory and files. Look through the existing content to determine if an existing file should be updated or a new file/directory added.
It will be very helpful to view the rendered documentation as you're editing. To do that run the following from the top-level directory:
```shell
docker compose -f docker-compose-mkdocs.yml -p mkdocs up
```
You can access the live documentation rendering at <http://localhost:8000>.

View file

@ -1,3 +1,5 @@
# Running on RaspberryPi
To run this image on a RaspberryPi 3 B+, 4, or newer, use any of the image tags [list in the Java version section](../versions/java.md) that specify `armv7` for the architecture, which includes `itzg/minecraft-server:latest`.
!!! note

View file

@ -2,37 +2,39 @@
To manage a CurseForge modpack automatically with upgrade support, pinned or latest version tracking, set `TYPE` to "AUTO_CURSEFORGE". The appropriate mod loader (Forge / Fabric) version will be automatically installed as declared by the modpack. This mode will also take care of cleaning up unused files installed by previous versions of the modpack, but world data is never auto-removed.
> **NOTES:**
>
> A CurseForge API key is **required** to use this feature. Go to their [developer console](https://console.curseforge.com/), generate an API key, and set the environment variable `CF_API_KEY`.
>
> When entering your API Key in a docker compose file you will need to escape any `$` character with a second `$`.
>
> Example if your key is `$11$22$33aaaaaaaaaaaaaaaaaaaaaaaaaa`:
> ```yaml
> environment:
> CF_API_KEY: '$$11$$22$$33aaaaaaaaaaaaaaaaaaaaaaaaaa'
> ```
> If you use `docker run` you will need to make sure to use single quotes:
>
> ```shell
> docker run ... -e CF_API_KEY='$11$22$33aaaaaaaaaaaaaaaaaaaaaaaaaa'
> ```
>
> To avoid exposing the API key, it is highly recommended to use a `.env` file, which is [loaded automatically by docker compose](https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-with-an-env-file). `$`'s in the value still need to escaped with a second `$` and the variable needs to be referenced from the compose file, such as:
> ```yaml
> environment:
> CF_API_KEY: ${CF_API_KEY}
> ```
>
> To use the equivalent with `docker run` you need to specify the `.env` file explicitly:
> ```
> docker run --env-file=.env itzg/minecraft-server
> ```
>
> Be sure to use the appropriate [image tag for the Java version compatible with the modpack](../versions/java.md).
>
> Most modpacks require a good amount of memory, so it best to set `MEMORY` to at least "4G" since the default is only 1 GB.
!!! warning "CurseForge API key usage"
A CurseForge API key is **required** to use this feature. Go to their [developer console](https://console.curseforge.com/), generate an API key, and set the environment variable `CF_API_KEY`.
When entering your API Key in a docker compose file you will need to escape any `$` character with a second `$`.
Example if your key is `$11$22$33aaaaaaaaaaaaaaaaaaaaaaaaaa`:
```yaml
environment:
CF_API_KEY: '$$11$$22$$33aaaaaaaaaaaaaaaaaaaaaaaaaa'
```
If you use `docker run` you will need to make sure to use single quotes:
```shell
docker run ... -e CF_API_KEY='$11$22$33aaaaaaaaaaaaaaaaaaaaaaaaaa'
```
To avoid exposing the API key, it is highly recommended to use a `.env` file, which is [loaded automatically by docker compose](https://docs.docker.com/compose/environment-variables/set-environment-variables/#substitute-with-an-env-file). `$`'s in the value still need to escaped with a second `$` and the variable needs to be referenced from the compose file, such as:
```yaml
environment:
CF_API_KEY: ${CF_API_KEY}
```
To use the equivalent with `docker run` you need to specify the `.env` file explicitly:
```
docker run --env-file=.env itzg/minecraft-server
```
!!! note
Be sure to use the appropriate [image tag for the Java version compatible with the modpack](../versions/java.md).
Most modpacks require a good amount of memory, so it best to set `MEMORY` to at least "4G" since the default is only 1 GB.
Use one of the following to specify the modpack to install:
@ -143,3 +145,67 @@ If your server's modpack fails to load with an error [like this](https://support
then you apply a workaround by adding this to the run invocation:
-e FTB_LEGACYJAVAFIXER=true
## ForgeAPI usage to use non-version specific projects
!!! warning "Deprecated"
This approach will soon be deprecated in favor of a variation of `AUTO_CURSEFORGE` mechanism described above.
!!! warning
This potentially could lead to unexpected behavior if the Mod receives an update with unexpected behavior.
This is more complicated because you will be pulling/using the latest mod for the release of your game. To get started make sure you have a [CursedForge API Key](https://docs.curseforge.com/#getting-started). Then use the environmental parameters in your docker build.
Please be aware of the following when using these options for your mods:
* Mod Release types: Release, Beta, and Alpha.
* Mod dependencies: Required and Optional
* Mod family: Fabric, Forge, and Bukkit.
Parameters to use the ForgeAPI:
* `MODS_FORGEAPI_KEY` - Required
* `MODS_FORGEAPI_FILE` - Required or use MODS_FORGEAPI_PROJECTIDS (Overrides MODS_FORGEAPI_PROJECTIDS)
* `MODS_FORGEAPI_PROJECTIDS` - Required or use MODS_FORGEAPI_FILE
* `MODS_FORGEAPI_RELEASES` - Default is release, Options: [Release|Beta|Alpha]
* `MODS_FORGEAPI_DOWNLOAD_DEPENDENCIES` - Default is False, attempts to download required mods (releaseType Release) defined in Forge.
* `MODS_FORGEAPI_IGNORE_GAMETYPE` - Default is False, Allows for filtering mods on family type: FORGE, FABRIC, and BUKKIT. (Does not filter for Vanilla or custom)
* `REMOVE_OLD_FORGEAPI_MODS` - Default is False
* `REMOVE_OLD_DATAPACKS_DEPTH` - Default is 1
* `REMOVE_OLD_DATAPACKS_INCLUDE` - Default is *.jar
Example of expected forge api project ids, releases, and key:
```yaml
MODS_FORGEAPI_PROJECTIDS: 306612,256717
MODS_FORGEAPI_RELEASES: Release
MODS_FORGEAPI_KEY: $WRX...
```
Example of expected ForgeAPI file format.
**Field Description**:
* `name` is currently unused, but can be used to document each entry.
* `projectId` id is the id found on the CurseForge website for a particular mod
* `releaseType` Type corresponds to forge's R, B, A icon for each file. Default Release, options are (release|beta|alpha).
* `fileName` is used for version pinning if latest file will not work for you.
```json
[
{
"name": "fabric api",
"projectId": "306612",
"releaseType": "release"
},
{
"name": "fabric voice mod",
"projectId": "416089",
"releaseType": "beta"
},
{
"name": "Biomes o plenty",
"projectId": "220318",
"fileName": "BiomesOPlenty-1.18.1-15.0.0.100-universal.jar",
"releaseType": "release"
}
]
```

View file

@ -1,4 +1,4 @@
### Optional plugins, mods, and config attach points
## Optional plugins, mods, and config attach points
There are optional volume paths that can be attached to supply content to be copied into the data area:
@ -11,7 +11,7 @@ There are optional volume paths that can be attached to supply content to be cop
`/config`
: contents are synchronized into `/data/config` by default, but can be changed with `COPY_CONFIG_DEST`. The source can be changed by setting `COPY_CONFIG_SRC`. For example, `-v ./config:/config -e COPY_CONFIG_DEST=/data` will allow you to copy over files like `bukkit.yml` and so on directly into the server directory. Set `SYNC_SKIP_NEWER_IN_DESTINATION=false` if you want files from `/config` to take precedence over newer files in `/data/config`.
By default, the [environment variable processing](../configuration/misc-options.md#replacing-variables-inside-configs) is performed on synchronized files that match the expected suffixes in `REPLACE_ENV_SUFFIXES` (by default "yml,yaml,txt,cfg,conf,properties,hjson,json,tml,toml") and are not excluded by `REPLACE_ENV_VARIABLES_EXCLUDES` and `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. This processing can be disabled by setting `REPLACE_ENV_DURING_SYNC` to `false`.
By default, the [environment variable processing](../configuration/interpolating.md) is performed on synchronized files that match the expected suffixes in `REPLACE_ENV_SUFFIXES` (by default "yml,yaml,txt,cfg,conf,properties,hjson,json,tml,toml") and are not excluded by `REPLACE_ENV_VARIABLES_EXCLUDES` and `REPLACE_ENV_VARIABLES_EXCLUDE_PATHS`. This processing can be disabled by setting `REPLACE_ENV_DURING_SYNC` to `false`.
If you want old mods/plugins to be removed before the content is brought over from those attach points, then add `-e REMOVE_OLD_MODS=TRUE`. You can fine tune the removal process by specifying the `REMOVE_OLD_MODS_INCLUDE` and `REMOVE_OLD_MODS_EXCLUDE` variables, which are comma separated lists of file glob patterns. If a directory is excluded, then it and all of its contents are excluded. By default, only jars are removed.
@ -21,9 +21,9 @@ For example: `-e REMOVE_OLD_MODS=TRUE -e REMOVE_OLD_MODS_INCLUDE="*.jar" -e REMO
These paths work well if you want to have a common set of modules in a separate location, but still have multiple worlds with different server requirements in either persistent volumes or a downloadable archive.
> For more flexibility with mods/plugins preparation, you can declare directories to use in [the `MODS` variable](#downloadable-modplugin-pack-for-forge-fabric-and-bukkit-like-servers)
> For more flexibility with mods/plugins preparation, you can declare directories to use in [the `MODS` variable](#zip-file-modpack)
### Auto-downloading SpigotMC/Bukkit/PaperMC plugins with Spiget
## Auto-downloading SpigotMC/Bukkit/PaperMC plugins with Spiget
The `SPIGET_RESOURCES` variable can be set with a comma-separated list of SpigotMC resource IDs to automatically download [SpigotMC resources/plugins](https://www.spigotmc.org/resources/) using [the spiget API](https://spiget.org/). Resources that are zip files will be expanded into the plugins directory and resources that are simply jar files will be moved there.
@ -38,9 +38,9 @@ For example, the following will auto-download the [EssentialsX](https://www.spig
-e SPIGET_RESOURCES=9089,34315
### Auto-download mods from Modrinth
## Auto-download mods and plugins from Modrinth
[Modrinth](https://modrinth.com/) is an open source modding platform with a clean, easy to use website for finding [Fabric and Forge mods](https://modrinth.com/mods). At startup, the container will automatically locate and download the newest versions of mod files that correspond to the `TYPE` and `VERSION` in use. Older file versions downloaded previously will automatically be cleaned up.
[Modrinth](https://modrinth.com/) is an open source modding platform with a clean, easy to use website for finding [Fabric and Forge mods](https://modrinth.com/mods). At startup, the container will automatically locate and download the newest versions of mod/plugin files that correspond to the `TYPE` and `VERSION` in use. Older file versions downloaded previously will automatically be cleaned up.
- **MODRINTH_PROJECTS** : comma separated list of project slugs (short name) or IDs. The project ID can be located in the "Technical information" section. The slug is the part of the page URL that follows `/mod/`:
```
@ -56,86 +56,31 @@ For example, the following will auto-download the [EssentialsX](https://www.spig
- **MODRINTH_DOWNLOAD_OPTIONAL_DEPENDENCIES**=true : required dependencies of the project will _always_ be downloaded and optional dependencies can also be downloaded by setting this to `true`
- **MODRINTH_ALLOWED_VERSION_TYPE**=release : the version type is used to determine the newest version to use from each project. The allowed values are `release`, `beta`, `alpha`.
### Downloadable mod/plugin pack for Forge, Fabric, and Bukkit-like Servers
## Zip file modpack
Like the `WORLD` option above, you can specify the URL or path of a "mod pack"
to download and install into `mods` for Forge/Fabric or `plugins` for Bukkit/Spigot.
To use this option pass the environment variable `MODPACK`, such as
docker run -d -e MODPACK=http://www.example.com/mods/modpack.zip ...
```shell
docker run -d -e MODPACK=http://www.example.com/mods/modpack.zip ...
```
**NOTE:** The referenced URL must be a zip file with one or more jar files at the
top level of the zip archive. Make sure the jars are compatible with the
particular `TYPE` of server you are running.
!!! note
The referenced URL must be a zip file with one or more jar files at the
top level of the zip archive. Make sure the jars are compatible with the
particular `TYPE` of server you are running.
You may also download or copy over individual mods using the `MODS` environment variable. `MODS` contains a comma-separated list of
- URL of a jar file
- container path to a jar file
- container path to a directory containing jar files
docker run -d -e MODS=https://www.example.com/mods/mod1.jar,/plugins/common,/plugins/special/mod2.jar ...
### ForgeAPI usage to use non-version specific projects
**NOTE:** This potentially could lead to unexpected behavior if the Mod receives an update with unexpected behavior.
This is more complicated because you will be pulling/using the latest mod for the release of your game. To get started make sure you have a [CursedForge API Key](https://docs.curseforge.com/#getting-started). Then use the environmental parameters in your docker build.
Please be aware of the following when using these options for your mods:
* Mod Release types: Release, Beta, and Alpha.
* Mod dependencies: Required and Optional
* Mod family: Fabric, Forge, and Bukkit.
Parameters to use the ForgeAPI:
* `MODS_FORGEAPI_KEY` - Required
* `MODS_FORGEAPI_FILE` - Required or use MODS_FORGEAPI_PROJECTIDS (Overrides MODS_FORGEAPI_PROJECTIDS)
* `MODS_FORGEAPI_PROJECTIDS` - Required or use MODS_FORGEAPI_FILE
* `MODS_FORGEAPI_RELEASES` - Default is release, Options: [Release|Beta|Alpha]
* `MODS_FORGEAPI_DOWNLOAD_DEPENDENCIES` - Default is False, attempts to download required mods (releaseType Release) defined in Forge.
* `MODS_FORGEAPI_IGNORE_GAMETYPE` - Default is False, Allows for filtering mods on family type: FORGE, FABRIC, and BUKKIT. (Does not filter for Vanilla or custom)
* `REMOVE_OLD_FORGEAPI_MODS` - Default is False
* `REMOVE_OLD_DATAPACKS_DEPTH` - Default is 1
* `REMOVE_OLD_DATAPACKS_INCLUDE` - Default is *.jar
Example of expected forge api project ids, releases, and key:
```yaml
MODS_FORGEAPI_PROJECTIDS: 306612,256717
MODS_FORGEAPI_RELEASES: Release
MODS_FORGEAPI_KEY: $WRX...
```shell
docker run -d -e MODS=https://www.example.com/mods/mod1.jar,/plugins/common,/plugins/special/mod2.jar ...
```
Example of expected ForgeAPI file format.
**Field Description**:
* `name` is currently unused, but can be used to document each entry.
* `projectId` id is the id found on the CurseForge website for a particular mod
* `releaseType` Type corresponds to forge's R, B, A icon for each file. Default Release, options are (release|beta|alpha).
* `fileName` is used for version pinning if latest file will not work for you.
```json
[
{
"name": "fabric api",
"projectId": "306612",
"releaseType": "release"
},
{
"name": "fabric voice mod",
"projectId": "416089",
"releaseType": "beta"
},
{
"name": "Biomes o plenty",
"projectId": "220318",
"fileName": "BiomesOPlenty-1.18.1-15.0.0.100-universal.jar",
"releaseType": "release"
}
]
```
### Generic pack files
## Generic pack files
To install all the server content (jars, mods, plugins, configs, etc.) from a zip or tgz file, then set `GENERIC_PACK` to the container path or URL of the archive file. This can also be used to apply a CurseForge modpack that is missing a server start script and/or Forge installer.
@ -153,9 +98,9 @@ would expand to `https://cdn.example.org/configs-v9.0.1.zip,https://cdn.example.
If applying large generic packs, the update can be time-consuming. To skip the update set `SKIP_GENERIC_PACK_UPDATE_CHECK` to "true". Conversely, the generic pack(s) can be forced to be applied by setting `FORCE_GENERIC_PACK_UPDATE` to "true".
The most time consuming portion of the generic pack update is generating and comparing the SHA1 checksum. To skip the checksum generation, set `SKIP_GENERIC_PACK_CHECKSUM` to "true.
The most time-consuming portion of the generic pack update is generating and comparing the SHA1 checksum. To skip the checksum generation, set `SKIP_GENERIC_PACK_CHECKSUM` to "true.
### Mod/Plugin URL Listing File
## Mod/Plugin URL Listing File
As an alternative to `MODS`, the variable `MODS_FILE` can be set with the path to a text file listing a mod/plugin URL on each line. For example, the following
@ -180,16 +125,16 @@ https://edge.forgecdn.net/files/2871/647/ToastControl-1.15.2-3.0.1.jar
It is recommended to combine this option with `REMOVE_OLD_MODS=TRUE` to ensure the mods/plugins remain consistent with the file's listing.
### Remove old mods/plugins
## Remove old mods/plugins
When the `MODPACK` option above is specified you can also instruct script to delete old mods/plugins prior to installing new ones. This behaviour is desirable in case you want to upgrade mods/plugins from downloaded zip file.
When the option above is specified (`MODPACK`) you can also instruct script to
delete old mods/plugins prior to installing new ones. This behaviour is desirable
in case you want to upgrade mods/plugins from downloaded zip file.
To use this option pass the environment variable `REMOVE_OLD_MODS=TRUE`, such as
docker run -d -e REMOVE_OLD_MODS=TRUE -e MODPACK=http://www.example.com/mods/modpack.zip ...
```shell
docker run -d -e REMOVE_OLD_MODS=TRUE -e MODPACK=http://www.example.com/mods/modpack.zip ...
```
!!! danger
All content of the `mods` or `plugins` directory will be deleted
before unpacking new content from the MODPACK or MODS.
All content of the `mods` or `plugins` directory will be deleted before unpacking new content from the MODPACK or MODS.

View file

@ -1,3 +1,5 @@
# Packwiz Modpacks
[packwiz](https://packwiz.infra.link/) is a CLI tool for maintaining and providing modpack definitions, with support for both CurseForge and Modrinth as sources. See the [packwiz tutorial](https://packwiz.infra.link/tutorials/getting-started/) for more information.
To configure server mods using a packwiz modpack, set the `PACKWIZ_URL` environment variable to the location of your `pack.toml` modpack definition:
@ -8,7 +10,7 @@ docker run -d -v /path/on/host:/data -e TYPE=FABRIC \
itzg/minecraft-server
```
packwiz modpack defitions are processed before other mod definitions (`MODPACK`, `MODS`, etc.) to allow for additional processing/overrides you may want to perform (in case of mods not available via Modrinth/CurseForge, or you do not maintain the pack).
packwiz modpack definitions are processed before other mod definitions (`MODPACK`, `MODS`, etc.) to allow for additional processing/overrides you may want to perform (in case of mods not available via Modrinth/CurseForge, or you do not maintain the pack).
!!! note

View file

@ -31,10 +31,10 @@ Plugins can either be managed within the `plugins` subdirectory of the [data dir
-e VERSION=b1.7.3 -e TYPE=CANYON
!!! note
!!! important
Only `VERSION=b1.7.3` is supported. Since that version pre-dates the health check mechanism used by this image, that will need to be disabled by setting `DISABLE_HEALTHCHECK=true`.
By default, the latest build will be used; however, a specific build number can be selected by setting `CANYON_BUILD`, such as
Canyon is on a temporary hiatus, so by default the final build from GitHub will be used; however, a specific build number can be selected in some instances by setting `CANYON_BUILD`, such as
-e CANYON_BUILD=11
-e CANYON_BUILD=6
-e CANYON_BUILD=26

View file

@ -44,3 +44,22 @@ Extra variables:
- `FORCE_REDOWNLOAD=false` : set to true to force the located server jar to be re-downloaded
- `USE_FLARE_FLAGS=false` : set to true to add appropriate flags for the built-in [Flare](https://blog.airplane.gg/flare) profiler
- `PURPUR_DOWNLOAD_URL=<url>` : set URL to download Purpur from custom URL.
### Folia
Enable Folia server mode by adding a `-e TYPE=FOLIA` to your command-line.
By default, the container will run the latest build of [Folia server](https://papermc.io/downloads), but you can also choose to run a specific build with `-e FOLIABUILD=26`.
docker run -d -v /path/on/host:/data \
-e TYPE=FOLIA \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
If you are hosting your own copy of Folia you can override the download URL with `FOLIA_DOWNLOAD_URL=<url>`.
If you have attached a host directory to the `/data` volume, then you can install plugins via the `plugins` subdirectory. You can also [attach a `/plugins` volume](../mods-and-plugins/index.md#optional-plugins-mods-and-config-attach-points). If you add plugins while the container is running, you'll need to restart it to pick those up.
[You can also auto-download plugins using `SPIGET_RESOURCES`.](../mods-and-plugins/index.md#auto-downloading-spigotmcbukkitpapermc-plugins-with-spiget)
!!! note
The Folia type inherits from the Paper type. Paper's variables will override the Folia ones.

View file

@ -1,5 +1,5 @@
---
site_name: Minecraft Server on Docker
site_name: Minecraft Server on Docker (Java Edition)
site_url: https://docker-minecraft-server.readthedocs.io/
site_description: Documentation for Minecraft Server on Docker
repo_url: https://github.com/itzg/docker-minecraft-server
@ -31,7 +31,7 @@ extra_css:
markdown_extensions:
- admonition
- toc:
permalink:
permalink: true
- attr_list
- def_list
- tables