/bitnami-tomcat9-jdk18

Customized Bitnami Tomcat Docker Image: Tomcat 9.0.34 + JDK 1.8 + additional management roles + allow management from any IP address

Primary LanguageShellApache License 2.0Apache-2.0

Build Status Docker Pulls Hits License

Customized Bitnami Tomcat 9

Customizations

Clone Bitnami Tomcat repo - 9.0.34-debian-10-r4 release

git clone git@github.com:bitnami/bitnami-docker-tomcat.git
cd bitnami-docker-tomcat
git checkout 8ee5c7c32ad71bc6287c68b304743f2c84964198
cd 9.0/debian-10

Change JDK version

Install JDK 1.8 instead of JDK 11.0.6-0

Edit Dockerfile

    FROM docker.io/bitnami/minideb:buster

    # removed for brevity

    # RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "java" "11.0.6-0" --checksum f7446f8bec72b6b2606d37ba917accc243e6cd4e722700c39ef83832c46fb0c6
    RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "java" "1.8.242-0" --checksum 3a70f3d1c3cd9bc6ec581b2a10373a2b323c0b9af40402ce8d19aeb0b3d02400

    # removed for brevity

JDK package location: java-1.8.242-0-linux-amd64-debian-10.tar.gz

Add Tomcat management roles

Edit bitnami-docker-tomcat/rootfs/opt/bitnami/scripts/libtomcat.sh

    # removed for brevity

    tomcat_create_tomcat_user() {
        local username=${1:?username is missing}
        local password=${2:-}

        local user_definition="<user username=\"${username}\" password=\"${password}\" roles=\"manager-gui,admin-gui,admin-script,manager-script,manager-jmx,manager-status\"/></tomcat-users>"

        replace_in_file "$TOMCAT_USERS_CONF_FILE" "</tomcat-users>" "$user_definition"
    }

    # removed for brevity

Allow management operations from any IP address

Edit bitnami-docker-tomcat/rootfs/opt/bitnami/scripts/libtomcat.sh

    # removed for brevity

    tomcat_env() {
        cat <<"EOF"
    ## Exposed

    ## removed
    export TOMCAT_ALLOW_REMOTE_MANAGEMENT_ANY_IP="${TOMCAT_ALLOW_REMOTE_MANAGEMENT_ANY_IP:-0}"
    EOF
    }

    # removed for brevity
    # removed for brevity

    tomcat_enable_remote_management() {

        # removed for brevity

        if is_boolean_yes "$TOMCAT_ALLOW_REMOTE_MANAGEMENT_ANY_IP"; then
            inner_tag=""
        else
            inner_tag=$(tomcat_render_tag Valve "className=\"org.apache.catalina.valves.RemoteAddrValve\" allow=\"\\\d+\\\.\\\d+\\\.\\\d+\\\.\\\d+\"")
        fi

        # removed for brevity
    }

    # removed for brevity

bitnami-tomcat9-jdk18 published on DockerHub

Run image

docker login
docker run --name t9 -d --rm -p 8080:8080 -p 8443:8443 andriykalashnykov/bitnami-tomcat9-jdk18:latest

Test image

docker exec -t t9 sh -c "cat /opt/bitnami/tomcat/conf/server.xml"
docker exec -t t9 sh -c "cat /opt/bitnami/tomcat/logs/catalina.*.log | grep 'APR'"
docker exec -t t9 sh -c "cat /opt/bitnami/tomcat/conf/tomcat-users.xml | grep 'admin-script'"
docker exec -t t9 sh -c "curl http://localhost:8080/"

Stop image

docker stop t9

Links