Tomcat dynamically configured by Consul-Template
213
These alpine-based images provide Apache Tomcat dynamically configured via Consul-Template. Please note these images do NOT include Java. You should install your desired version/flavor of Java in a derived image.
Use the TOMCAT_PREFIX environment variable to set the key prefix where the
tomcat configuration will be found in Consul. If not set, service/tomcat
will be used.
Also, you must set CONSUL_HTTP_ADDR in order for consul-template to render
any templates when the container runs. Any supported consul-template environment
variables can be used, such as:
| Environment Variable | Description | Default |
|---|---|---|
TOMCAT_HTTP_PORT | HTTP connector port | 8080 |
TOMCAT_JMX_PORT | JMX port (if enabled) | 1099 |
JPDA_ADDRESS | Debug port (use catalina.sh jpda run to enable) | 8000 |
TOMCAT_RMI_HOSTNAME | RMI server hostname/IP (needed for JMX) | localhost |
setenv.sh Settings| Consul Key | Environment Variable | Description |
|---|---|---|
<prefix>/initial_heap_size | TOMCAT_HEAP_INITIAL | sets JVM -Xms |
<prefix>/max_heap_size | TOMCAT_HEAP_MAX | sets JVM -Xmx |
<prefix>/max_perm_size | TOMCAT_MAX_PERM_SIZE | sets JVM -XX:MaxPermSize |
<prefix>/jmx/enabled | TOMCAT_JMX_ENABLED | enable/disable JMX (disabled by default) |
<prefix>/catalina_opts | CATALINA_OPTS | additional space or linefeed delimited java options passed as CATALINA_OPTS to tomcat. |
The following setting are only relevant if JMX is enabled (see above). All settings are optional, and have no defaults unless shown.
| Consul Key | Environment Variable | Description |
|---|---|---|
<prefix>/jmx/authenticate | TOMCAT_JMX_AUTHENTICATE | whether JMX auth is enabled (default: true) |
| N/A | TOMCAT_JMX_READONLY_USERNAME | username for a JMX readonly user |
| N/A | TOMCAT_JMX_READONLY_PASSWORD | password for a JMX readonly user |
| N/A | TOMCAT_JMX_READWRITE_USERNAME | username for a JMX readwrite user |
| N/A | TOMCAT_JMX_READWRITE_PASSWORD | password for a JMX readwrite user |
| N/A | TOMCAT_JMX_ACCESS_FILE | path to JMX access file (default: conf/jmxremote.access) |
| N/A | TOMCAT_JMX_PASSWORD_FILE | path to JMX password file (default: conf/jmxremote.password) |
<prefix>/jmx/users/<user>/access | N/A | readonly or readwrite access for given JMX user |
<prefix>/jmx/users/<user>/password | N/A | password for given JMX user |
tomcat-users.xml SettingsThe following Consul keys are optional and used to configure tomcat-users.xml.
| Consul Key | Description |
|---|---|
<prefix>/roles | comma-delimited list of roles in tomcat-users.xml |
<prefix>/users/<user> | username(s) in tomcat-users.xml |
<prefix>/users/<user>/password | password for tomcat user |
<prefix>/users/<user>/roles | comma-delimited list of roles for tomcat user |
server.xml Settings| Consul Key | Description |
|---|---|
<prefix>/executor/<attribute> | attribute(s) for optional shared executor |
<prefix>/http_connector/<attribute> | optional attribute(s) for HTTP connector |
<prefix>/engine_valves/<className>/<attribute> | optional map of engine valves |
<prefix>/host_valves/<className>/<attribute> | optional map of host valves |
When the container is launched, any file in the following directories ending with
.ctmpl will be rendered to a file with the same name with .ctmpl stripped:
For example, /usr/local/tomcat/conf/server.xml.ctmpl will be rendered as
/usr/local/tomcat/conf/server.xml. Derived images can use this by adding additional
files in these directories, and expect them to be rendered at runtime.
bin/setenv.d DirectoryRather than overwriting bin/setenv.sh in derived images, you can add additional
file(s) to bin/setenv.d and they will be sourced by the main setenv.sh script
at runtime.
/entrypoint.d DirectoryThe image's entrypoint script is configured to source any files contained in /entrypoint.d
immediately before starting tomcat. This can be used to execute basic scripts
added by derived images that might need to execute at runtime.
Content type
Image
Digest
Size
11.8 MB
Last updated
about 8 years ago
docker pull steadyserv/tomcat-consul:7