i cannot configure a Dockerfile for use external properties file with Spring Boot. This is my Dockerfile:
FROM java:8-jre
VOLUME /tmp /var/gpm/config
ADD gpm-web-1.0.jar app.jar
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-cp","/var/gpm/config","-Dspring.config.location=classpath:application.properties","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
And in my host i have this path to properties file : /var/gpm/config/application.properties
But, don't works.
UPDATE
i change Dockerfile by this:
FROM java:8-jre
VOLUME /tmp
ADD gpm-web-1.0.jar app.jar
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar","--spring.config.location=file:/conf/application.properties"]
And run with this:
docker run -d -p 8080:8080 -v /opt/gpm/config/application.properties:/conf/application.properties --name gpm gpm-web:1.0
But, the file is take it like a folder:
root@b7349202b6d3:/# ls -la /conf/
total 8
drwxr-xr-x 3 root root 4096 May 18 16:43 .
drwxr-xr-x 74 root root 4096 May 18 16:55 ..
drwxr-sr-x 2 root staff 40 May 18 16:43 application.properties
I think you only need to mount the volume to the conf folder e.g.
docker run -d -p 8080:8080 -v /opt/gpm/config:/conf --name gpm gpm-web:1.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With