作业描述:
(1)Hot是应用程序(springboot),打成jar包:docker-demo-1.0-SNAPSHOT.jar
(2)利用dockerfile将docker-demo-1.0-SNAPSHOT.jar构建成镜像docker-demo
Dockerfile-docker-demo:
# 基于Java 9FROM java:9# 设置工作目录WORKDIR /app# 复制文件到工作目录COPY . /app# 设置Java环境变量ENV PATH=$PATH:$JAVA_HOME/binENV JRE_HOME=${JAVA_HOME}/jreENV CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib# 编译#RUN ["/usr/lib/jvm/java-9-openjdk-amd64/bin/java", "-jar", "docker-demo-1.0-SNAPSHOT.jar"]# 运行
CMD ["/usr/lib/jvm/java-9-openjdk-amd64/bin/java", "-jar", "docker-demo-1.0-SNAPSHOT.jar"]
#ENTRYPOINT ["/usr/lib/jvm/java-9-openjdk-amd64/bin/java", "-jar", "docker-demo-1.0-SNAPSHOT.jar"]
构建镜像
[root@k8s-master javadocker]# docker build -f Dockerfile-docker-demo -t docker-demo:latest .
查看镜像
[root@k8s-master javadocker]# docker images
执行镜像
[root@k8s-master javadocker]# docker run docker-demo