6

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 
12
  • Have you bashed into the container when running and checked if the files are available in the volume?
    – Shibashis
    Commented May 18, 2016 at 15:57
  • Hi!, the folder it's mounted, but the folder is empty, cannot see the application.properties file.
    – Paolo Soto
    Commented May 18, 2016 at 16:46
  • Use docker inspect <container id> command and check the Mounts
    – Shibashis
    Commented May 18, 2016 at 16:52
  • i update this post, the inspect command shows: "Mounts": [ { "Source": "/opt/gpm/config/application.properties", "Destination": "/conf/application.properties", "Mode": "", "RW": true }
    – Paolo Soto
    Commented May 18, 2016 at 16:59
  • ls -la /conf/ where did you execute it? so it seems to be available, you earlier said folder is empty
    – Shibashis
    Commented May 18, 2016 at 17:07

2 Answers 2

1

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

0

Finally, the problem is about permissions of the file to be mounted in Docker container. Docker creates a directory if the original file is not found in host.

Thanks to @Shibashis for the help.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.