文件名为:po-1.0-SNAPSHOT.jar
创建目录:
/data/docker/springboot_demo
目录下新建文件
Dockerfile文件内容为:
FROM openjdk:11-jre-slim RUN apt-get update RUN apt-get -qq -y install wget RUN apt install fontconfig -y --force-yes && apt install --fix-broken -y --force-yes ENV JAVA_OPTS="-server -Xmx1g -Xms2g -Xmn1g -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -Dfile.encoding=UTF-8 -Duser.timezone=GMT+8" ENV TZ Asia/Shanghai VOLUME /data ARG JAR_FILE ADD ./${JAR_FILE}-1.0-SNAPSHOT.jar /data/docker/springboot_demo/app.jar WORKDIR /data/docker/springboot_demo ENTRYPOINT ["java","-jar","./app.jar"]
运行目录:
/data/docker/springboot_demo
运行命令:
docker build --build-arg JAR_FILE=po -t springboot_demo .
运行镜像:
docker run -p 6666:6666 --name springboot_demo -d springboot_demo
测试:
标签:springboot,--,demo,jar,data,004,docker,Dockerfile From: https://www.cnblogs.com/popopopopo/p/16806951.html