写点什么

制作 Docker 镜像,用来下载 OpenJDK11 源码,分享一点面试小经验

用户头像
极客good
关注
发布于: 刚刚

COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COP


【一线大厂Java面试题解析+核心总结学习笔记+最新架构讲解视频+实战项目源码讲义】
浏览器打开:qq.cn.hn/FTf 免费领取
复制代码


Y ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


COPY ./SRC_PATH/


#命令行文件复制到工作目录


COPY ./cmd.sh /


RUN chmod a+x /cmd.sh


CMD ["bash", "/cmd.sh"]


看到这里您一定会有疑问:这么多行 COPY 命令,为什么不用 OPENJDK_SRC_PACKAGE_NAME-*,这样岂不是一行命令就够了?


您可以在镜像 build 成功后,用 docker history 命令看看文件的 layer 数量,用多个 COPY 命令逐个执行,每个命令都对应一个小的 layer,这样用户下载镜像时就是在下载多个小文件了;

[](

)cmd.sh 文件


cmd.sh 的内容如下,可见当容器启动后,先将分割后的多个小文件通过 cat 命令恢复成完整的 jdk11.tar.gz 文件,再解压,然后删除 jdk11.tar.gz 文件:


echo "start build gz file"


cat OPENJDK_SRC_PACKAGE_NAME-* > /output/$OPENJDK_SRC_PACKAGE_NAME.tar.gz


echo "gz file build success, start unzip"


tar -zxvf /output/$OPENJDK_SRC_PACKAGE_NAME.tar.gz -C /output


echo "unzip success, start remove gz file"

用户头像

极客good

关注

还未添加个人签名 2021.03.18 加入

还未添加个人简介

评论

发布
暂无评论
制作Docker镜像,用来下载OpenJDK11源码,分享一点面试小经验