Passing Tomcat parameters to Docker

后端 未结 2 2162
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-10 01:01

I am new to Docker and I have a question that I can\'t seem to find the answer to. I am taking a Docker image (consol/tomcat-7.0) and wrote a Dockerfile that loads this image, c

2条回答
  •  花落未央
    2021-02-10 01:28

    The typical method for docker containers is passing via environment variables.

    Expanding on a solution to pass the port via command line the server.xml needs to be modified so it takes in properties from JAVA_OPTS

    For example in server.xml

    
        
    
    

    Then you can pass value of ${jdbc.url} from properties on the command line.

    JAVA_OPTS="-Djdbc.url=jdbc:mysql:mysqlhost:3306/"
    

    When running the docker image you use the -e flag to set this environment variable at run time

    $ docker run -it -e "JAVA_OPTS=-Djdbc.url=jdbc:mysql:mysqlhost:3306/" --rm myjavadockerimage /opt/tomcat/bin/deploy-and-run.sh
    

    Optionally also add a --add-host if you need to map mysqlhost to a specific ip address.

提交回复
热议问题