I am migrating a java standalone maven project in docker. As of now we create a jar file for this maven project and it runs with public static void main method.
java -cp app.jar com.xxx.ExportManager db.properties
After completion of this code it exports a file in its current directory.
Dockerfile
FROM centos:7
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
ENV echo $JAVA_HOME
RUN java -version
ARG JAR_FILE=target/manager.jar
ARG JAR_LIB_FILE=target/lib/
WORKDIR /opt/manager/app/
COPY ${JAR_FILE} app.jar
COPY conf/db.properties /opt/manager/app/db.properties
ADD ${JAR_LIB_FILE} lib/
ENTRYPOINT ["java","-jar","app.jar"]
Commands:
- Building image:
docker build -t pc .
- Run the main method:
docker run -t pc /opt/manager/app/db.properties
After run it's exporting file inside image (I am sure because i have checked it through loggers) to /opt/manager/app/. But when i see the contents of image using command
docker run -it --entrypoint sh pc
cd /opt/manager/app
the directory doesn't have exported file however it contains all other project files.
How to retain the exported file in the image?
PS: I'm new in docker, please forgive any mistakes.