Sign inSign up

steadyserv/tomcat-consul

By steadyserv

Updated about 8 years ago

Tomcat dynamically configured by Consul-Template

Image
0

213

steadyserv/tomcat-consul repository overview

bdclark/tomcat-consul Docker Images

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.

Supported Consul Keys and Environment Variables

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:

  • CONSUL_HTTP_ADDR
  • CONSUL_HTTP_TOKEN
  • CONSUL_HTTP_AUTH
  • CONSUL_HTTP_SSL
  • CONSUL_HTTP_SSL_VERIFY
Port Settings
Environment VariableDescriptionDefault
TOMCAT_HTTP_PORTHTTP connector port8080
TOMCAT_JMX_PORTJMX port (if enabled)1099
JPDA_ADDRESSDebug port (use catalina.sh jpda run to enable)8000
TOMCAT_RMI_HOSTNAMERMI server hostname/IP (needed for JMX)localhost
setenv.sh Settings
Consul KeyEnvironment VariableDescription
<prefix>/initial_heap_sizeTOMCAT_HEAP_INITIALsets JVM -Xms
<prefix>/max_heap_sizeTOMCAT_HEAP_MAXsets JVM -Xmx
<prefix>/max_perm_sizeTOMCAT_MAX_PERM_SIZEsets JVM -XX:MaxPermSize
<prefix>/jmx/enabledTOMCAT_JMX_ENABLEDenable/disable JMX (disabled by default)
<prefix>/catalina_optsCATALINA_OPTSadditional space or linefeed delimited java options passed as CATALINA_OPTS to tomcat.
JMX Security Settings

The following setting are only relevant if JMX is enabled (see above). All settings are optional, and have no defaults unless shown.

Consul KeyEnvironment VariableDescription
<prefix>/jmx/authenticateTOMCAT_JMX_AUTHENTICATEwhether JMX auth is enabled (default: true)
N/ATOMCAT_JMX_READONLY_USERNAMEusername for a JMX readonly user
N/ATOMCAT_JMX_READONLY_PASSWORDpassword for a JMX readonly user
N/ATOMCAT_JMX_READWRITE_USERNAMEusername for a JMX readwrite user
N/ATOMCAT_JMX_READWRITE_PASSWORDpassword for a JMX readwrite user
N/ATOMCAT_JMX_ACCESS_FILEpath to JMX access file (default: conf/jmxremote.access)
N/ATOMCAT_JMX_PASSWORD_FILEpath to JMX password file (default: conf/jmxremote.password)
<prefix>/jmx/users/<user>/accessN/Areadonly or readwrite access for given JMX user
<prefix>/jmx/users/<user>/passwordN/Apassword for given JMX user
tomcat-users.xml Settings

The following Consul keys are optional and used to configure tomcat-users.xml.

Consul KeyDescription
<prefix>/rolescomma-delimited list of roles in tomcat-users.xml
<prefix>/users/<user>username(s) in tomcat-users.xml
<prefix>/users/<user>/passwordpassword for tomcat user
<prefix>/users/<user>/rolescomma-delimited list of roles for tomcat user
server.xml Settings
Consul KeyDescription
<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

Template rendering

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:

  • /entrypoint.d
  • $CATALINA_HOME/conf
  • $CATALINA_HOME/lib
  • $CATALINA_HOME/bin
  • $CATALINA_HOME/bin/setenv.d

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 Directory

Rather 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 Directory

The 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.

Tag summary

Content type

Image

Digest

Size

11.8 MB

Last updated

about 8 years ago

docker pull steadyserv/tomcat-consul:7