Add JAVA_AGENTS and JVM_AGENTS to load agents from URLs and paths (#4356)

This commit is contained in:
Vitalii Kotenko authored and GitHub committed 2026-10-24 14:10:42 -05:00
1 parent b64207b3c9
commit 7c486b27b7
6 files changed
+90

No files matched your search

+27
View File
@@ -89,6 +89,33 @@ you can use
JVM_DD_OPTS: fml.queryResult=confirm,name=value
```
## Java and JVM Agents
Java agents, such as [authlib-injector](https://github.com/yushijinhun/authlib-injector), can be loaded into the server by setting `JAVA_AGENTS`, and native JVM agents by setting `JVM_AGENTS`. Like [the `MODS` / `PLUGINS` variables](../mods-and-plugins/index.md#modsplugins-list), both are a comma or newline delimited list of
- URL of an agent file
- container path to an agent file
- container path to a directory containing agent jar files for `JAVA_AGENTS`, or `.so` files for `JVM_AGENTS`
The agents are copied into `/data/agents/java` and `/data/agents/jvm`, and each one is passed to the JVM as `-javaagent:<file>` or `-agentpath:<file>`, in file name order.
!!! example
```yaml
environment:
JAVA_AGENTS: |
https://www.example.com/agents/agent.jar
/agents
```
!!! note "Auto-removal"
Entries that are removed from the `JAVA_AGENTS` or `JVM_AGENTS` list will be automatically removed from the agents directory, so they are no longer loaded.
!!! note "Agent options"
An agent that needs options, such as `-javaagent:agent.jar=options`, can still be passed with `JVM_OPTS` instead.
## Enable Remote JMX for Profiling
To enable remote JMX, such as for profiling with VisualVM or JMC, set the environment variable `ENABLE_JMX` to "true", set `JMX_HOST` to the IP/host running the Docker container, and add a port forwarding of TCP port 7091, such as: