External properties file using Spring Boot and Docker
12,233
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
Author by
Paolo Soto
Updated on June 09, 2022Comments
-
Paolo Soto almost 2 years
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