Issue
I am working with spring-boot along with docker images.
I am running my springboot
application directly from IntelliJ
name as runtime
with some of argument like below
-DCONFIG_DIR=D:\baseapimanager\runtime\config
I am able to run it successfully.
But by creating a docker image and running that image, it's not able to run. As i am not aware about how to pass argument while running docker image.
Here i had shared my Docker file contents as well.
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD target/docker-runtime.jar docker-runtime.jar
EXPOSE 8091
ENTRYPOINT ["java","-jar","docker-runtime.jar"]
And running below docker command i am trying to create image file for same.
docker build -f Dockerfile -t docker-runtime .
After this executing below command to run this generated image file.
docker run -p 8091:8091 docker-runtime
Without passing that argument and commenting business with that argument, it's working perfectly fine.
Any help will be appreciated.
Solution
I had made below changes in my Docker file.
FROM openjdk:8-jdk-alpine
VOLUME /tmp
ADD target/docker-runtime.jar docker-runtime.jar
EXPOSE 8091
ENTRYPOINT ["java","-jar","-DCONFIG_DIR=/shareddata","docker-runtime.jar"]
And while running an image i had bind that address using below command , and it's working fine.
docker run -p 8091:8091 --mount type=bind,source=/c/Users/lenovo/data,target=/shareddata docker-runtime
This had resolved my problem.
Answered By - Sagar Gangwal
Answer Checked By - Gilberto Lyons (JavaFixing Admin)