Configuration at the Command Line

Command line options for the docker run command can be used in addition to environment variables to configure Java-based Docker containers.

Command line options take priority over environment variable values. Make sure not to unintentionally override desired settings.

Note: You can specify JVM arguments (-Dxxxx and -Xxxxx) at the command line when executing Java control scripts. You can override default JVM arguments specified by individual component start scripts (for example: start_rsgateway.sh set -Xms512m -Xmx8g) by specifying a replacement value (rather than having to redefine all default values). For example, to specify the maximum JVM memory allocation pool when starting the RS Gateway, use the following command:
docker run --rm r.m0012242008.com:18080/rsgateway:5220 -Xms1g

Container Configuration Command Line Arguments describes the available command line arguments. Where no example is given, the option can be used as is without further arguments or values.

Table 1. Container Configuration Command Line Arguments
Option Description Equivalent Environment Variable Example Usage
--help Provides help and usage information.
--app-name, -n The name of the application. MTX_APP_NAME --app-name my-app
--args, -a The Java application arguments to use when running the Java process. If there are multiple arguments enclose the group of arguments in quotation marks. MTX_JAVA_ARGS

--args abc

-- args "abc def"

--classpath, -c The classpath to use when executing the Java process, as a comma-separated list of paths. MTX_JAVA_CP --classpath /opt/mtx/ext/common,/opt/mtx/ext/payment-service
--attached, -f Causes the application to start as an attached foreground process.

This option is automatically enabled when running within Docker as an active foreground process is required to keep the container alive.

--dry-run Displays the command that would be run with the configuration provided, for test purposes.
--healthcheck-url, -hu The URL to call once the application PID file has been created. The specified URL should return HTTP 200 when the application is healthy. This is used to check the process has started when running as a detached process or when running the check process script. MTX_HEALTHCHECK_URL --healthcheck-url http://localhost:9095/actuator/health
--healthcheck-port, -hp The port on the local machine (127.0.0.1) to check once the application PID file has been created. This port should be open for traffic once the application is healthy. This is used to check the process has started when running as a detached process or when running the check process script. MTX_HEALTHCHECK_PORT --healthcheck-port 4070
--healthcheck-timeout, -ht The amount of time to wait (in seconds) when performing a port-based or URL-based health check on the application. MTX_HEALTHCHECK_TIMEOUT --healthcheck-timeout 120
--jar-file, -jar The name of the JAR file to use in the Java command, set by the Docker container. MTX_JAR_FILENAME --jar-file my-app.jar
--jfr-enabled Indicates that the Java process is set to record for troubleshooting or analysis using Java Flight Recorder. This setting is not recommended for production. See the discussion about troubleshooting with Java Flight Recorder for more information. MTX_JFR_ENABLED
--jvm-args The JVM arguments to add when running the Java process. These arguments replace any existing JVM arguments. MTX_JVM_ARGS --jvm-args -Xss16m
--jvm-arg, -j A single JVM argument to add to existing JVM arguments when running the Java process. This does not replace existing JVM arguments.

You can submit JVM arguments beginning with -D and -X (such as -Xms512m or -Dlog4j2.debug) at the command line as if you were calling the Java command directly. See the note for more information.

--jvm-arg -Xss16m
--log-config -l The filename (optionally including the full path if outside of the classpath) of the Log4j 2.x configuration file to use. --log-config /opt/mtx/conf/log4j2-debug.xml
--mainclass, -m The fully qualified name of the Java Main class. This is only applicable if you the application type is set to java and is typically only required if you need to set additional classpath elements. MTX_JAVA_MAINCLASS --mainclass com.matrixx.example.​Main
--no-color Specifies monochrome output.
--no-healthcheck Causes healthcheck functionality to be skipped.
--no-wait This flag indicates that any 'wait for' functionality should be skipped.
--profiles, -p A comma separated list of Spring Boot profiles to enable, where applicable. MTX_SPRING_PROFILE --profiles debug,docker
--spring-boot, -sb Set the application to Spring Boot. If this is set, the Java command must be constructed in a different way when compared to a standard Java application. MTX_APP_TYPE='springboot'
--wait-for-host, -wh The host on which the port specified with --wait-for-port must have traffic before the Java process starts. MTX_WAIT_FOR_HOST --wait-for-host rsgateway
--wait-for-port, -wp The port on the host specified in --wait-for-host that must have traffic before the Java process starts. MTX_WAIT_FOR_PORT --wait-for-port 8080
--wait-for-timeout, -wt The amount of time in seconds to wait for a resource. This is only applicable if values for --wait-for-host and --wait-for-port have been specified. MTX_WAIT_FOR_TIMEOUT --wait-for-timeout 120
--verbose, -v Provides extra output to make troubleshooting easier.