I am hoping you can provide some guidance. I was reading the forum but I did no fully comprehend if there is a work around or if this is expected behavior.
I am currently experimenting with docker and creating persistent volumes with tomcat.
I have a WAR file that writes a tiny piece of information to a file in WEB-INF/APP-DATA/. I am doing this only for docker. But I am assuming that once I configure a volume my data can persist across restarts and rebuilds of the docker container.
I built a docker compose file as follow:
version: '3.8' services: tomcat: build: context: . dockerfile: ./Dockerfile container_name: MY-APP image: my-app:1.1.4 restart: unless-stopped ports: - "8080:8080" volumes: - ./logs:/usr/local/tomcat/logs - ./AppData:/usr/local/tomcat/webapps/MY-APP/WEB-INF/AppData
Here is the Dockerfile as follows:
FROM tomcat:9.0.59-jdk11 LABEL maintainer="max firstname.lastname@example.org" ADD ./target/MY-APP.war /usr/local/tomcat/webapps/ EXPOSE 8080 CMD ["catalina.sh", "run"]
When I use ./AppData:/usr/local/tomcat/webapps/MY-APP/WEB-INF/AppData and do docker-compose up The WAR file does not get exploded. I suspect tomcat does not do anything because it sees that MY-APP… already exist. Now if I map it as ./AppData:/usr/local/AppData then tomcat explodes the WAR file correctly.
So is my thinking incorrect about being able to write data into the MY-APP/WEB-INF/AppData then map a volume from the host?
Is there a special trick when I can tell docker to wait to map the volume once the WAR file has been explored or what is the general practice.
Thanks in advance for any guidance,