Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

External properties file using Spring Boot and Docker

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 
like image 668
Paolo Soto Avatar asked May 18 '16 13:05

Paolo Soto


1 Answers

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

like image 182
user3218881 Avatar answered Oct 04 '22 02:10

user3218881