I packaged a Spring boot app with its own application.properties file as a docker image. I will like whoever runs the image to provide his/her own property files (overriding the one inside the app) when running a container off the image. My Dockerfile looks like this.
# our base build image
FROM maven:3.6.2-jdk-11 as maven
WORKDIR /app
# copy the Project Object Model file
COPY ./pom.xml ./pom.xml
# fetch all dependencies
RUN mvn dependency:go-offline -B
# copy your other files
COPY ./src ./src
# build for release
# NOTE: my-project-* should be replaced with the proper prefix
RUN mvn package -Dmaven.test.skip=true && cp target/myApp.jar app.jar
# smaller, final base image
FROM openjdk:8-jdk-alpine
# OPTIONAL: copy dependencies so the thin jar won't need to re-download them
# COPY --from=maven /root/.m2 /root/.m2
# set deployment directory
WORKDIR /app
# copy over the built artifact from the maven image
COPY --from=maven /app/app.jar ./app.jar
# set the startup command to run your binary
CMD ["java", "-jar", "/app/app.jar"]
I run the image as follows.
docker run -p 8085:8085 docker-spring-boot-name
How do I use an external application properties. I have read similar answers, but I seem to not to understand, although, I don't think I have a unique issue.?