Docker Community Forums

Share and learn in the Docker community.

Add external windows folder in classpath for docker tomcat with docker-compose

#1

I am new to docker & docker-compose. I have a basic mysql-tomcat docker compose file as below. I am running docker on a windows 10 machine. I have my application.properties file in one of my windows directory . D:/configs/application.properties. How do I configure my docker-compose or docker in such a way that this property file is picked up by tomcat (configure in classpath) every time I deploy my application? I don’t want it to be part of my docker image as some of the properties are specific to machines/developers etc.

docker-componse up --detach

my docker-compose.yml

services:
    db:
        container_name: mysql_mydb
        image: mysql:latest
        command: --lower_case_table_names=1
        environment:
          - MYSQL_ROOT_PASSWORD=pass
        volumes:
            - ./mysql/data/initdb.d:/docker-entrypoint-initdb.d
            - ./mysql/data/mysql:/var/lib/mysql
        ports:
            - 3306:3306
    web:
        image: tomcat:latest
        container_name: tomcat
        # Environment variables do not appear to be getting loaded the first time Tomcat starts!
        environment:
         JDBC_URL: jdbc:mysql://db:3306/my_db?connectTimeout=0&socketTimeout=0&autoReconnect=true
         JDBC_USER: root
         JDBC_PASS: pass
        volumes:
        - ./tomcat/webapps:/usr/local/tomcat/webapps
        - ./tomcat/logs:/usr/local/tomcat/logs
        - ./tomcat/conf:/user/local/tomcat/conf
        - ./tomcat/docker-compose-setenv.sh:/usr/local/tomcat/bin/setenv.sh
        ports:
            - 9090:8080
        links:
            - db
#2

Still looking for some help on this. Has anyone come across such a scenario in a non spring boot case? I see lot of spring boot examples but I am dealing with a more traditional application here!