Overview
When you have mods or plugins requiring configuration information only available at deploy-time (like database connections or runtime server names), you can use variable interpolation to inject environment variables into your configuration files.Configuration File Interpolation
Basic Usage
Replace variables in all files inside
/data with matching environment variablesReplace variables in files synced from
/plugins, /mods, and /config directoriesPrefix required for environment variables to be replaced. Set to empty string to allow any variable name.
Variable Syntax
Variables use curly bracket syntax with a dollar sign prefix:Supported File Types
Variable replacement works with these file extensions:.yml.yaml.txt.cfg.conf.properties
Example Configuration
- Config File
- docker compose
database.yml
Using Secrets as Files
For sensitive values like passwords, declare placeholders in config files and use environment variables with the_FILE suffix pointing to mounted secrets.
Environment variable pointing to a file containing the actual value. The variable name should match the placeholder but with
_FILE suffix.Example with Docker Secrets
Exclusions
Exclude Specific Files
Comma or space-separated list of filenames (without path) to exclude from variable replacement
Exclude Paths
Space-separated list of paths to exclude from variable replacement. Exclusions are recursive.
Server Properties Placeholders
When declaring server properties via environment variables, you can use special placeholders that are processed whenserver.properties is updated.
Placeholder Types
Environment Variables:%VAR%- Replaced with value of environment variable VAR%env:VAR%- Explicit environment variable syntax
%date:FMT%- Formats current date/time using Java’s DateTimeFormatter
Available Variables
Any declared or resolved environment variable may be referenced:VERSION- Resolved Minecraft versionTYPE- Server typeDECLARED_VERSION- Originally declared version (e.g., “LATEST” or “SNAPSHOT”)MODPACK_NAME- Available with Modrinth and Auto CurseForge modpacksMODPACK_VERSION- Available with Modrinth and Auto CurseForge modpacks
Examples
Placeholders are not supported when manually managing
server.properties (when OVERRIDE_SERVER_PROPERTIES=false).Patching Existing Files
JSON path-based patches can be applied to existing files for more complex modifications.Path to a directory containing patch definition JSON files or a patch set JSON file. See mc-image-helper documentation for format details.
file and value fields in patch definitions support ${...} variable placeholders. Use REPLACE_ENV_VARIABLE_PREFIX to restrict allowed variables (defaults to “CFG_”).
Patch Set Example
patch-set.json
Supported Formats
Patch definitions support:- JSON
- JSON5
- YAML
- TOML (output is not pretty-printed)
Complete Example
compose.yaml
Best Practices
Use the
_FILE suffix pattern with Docker Secrets for sensitive values like passwords and API keys.Set
REPLACE_ENV_VARIABLE_PREFIX to limit which environment variables can be replaced, preventing accidental substitution.