docker - 在 dockerfile [解决] 中将 .zip 转换为 tar.gz
问题描述
我得到了下载 .zip 文件夹的 dockerfile,因为 docker 容器没有apt-get。我无法解压缩它,但似乎 .tar.gz convert 嵌入在 dockerfile 中。
如何在 dockerfile 中将 .zip 转换为 .tar.gz?
有什么选择吗?gunzip 也不起作用。
somezipfile.zip has more than one entry -- unchanged
Dockerfile 部分
RUN curl -LJO http://somelink.com/verynew_python.zip
RUN gunzip -S .zip verynew_python.zip
ADD verynew_python.tar.gz /usr/bin
RUN chmod +x /usr/bin/verynew_python/bin/python3.7
抱歉,我无法发布所有 dockerfile,但这是重要的部分。我想让python3.7作为主要的python ..也没有wget。
解决方案
您可以在您的 docker 容器中安装软件包 - 如果您可以自由选择这样的作品:
RUN apk add --no-cache unzip
WORKDIR /tmp
COPY testfile.zip .
RUN unzip testfile.zip
RUN rm testfile.zip
RUN tar czvf testfile.tgz *
这导致:
$ docker run -ti x sh
/tmp # ls
testfile testfile.tgz
/tmp #
这很不优雅,但很有效。如果您的基础映像来自 docker hub,您可以查找它是否构建在发行版上,如果是,则为它选择“正确”的包管理器 - 最常见的是apk
,yum
或apt
.
请记住 - 为了保持图像小 - 包缓存通常不可用,您需要apt update
像上面一样获取它们或必须使用非缓存方法。
推荐阅读
- angular - Angular Typescript FormGroup在提交后赋值
- javascript - 添加一个按钮以显示和隐藏 R 中的数据表
- javascript - 如果没有找到 querySelector(使用替换)
- ios - 如何检测何时选择了 TextView 但在它成为第一响应者之前?
- c# - 代码中没有错误,但尝试更新时表中没有发生变化
- javascript - 当 useState 更新时,map 循环在 useState 对象内部的数组中不起作用。反应js
- python - 我收到错误:django.db.utils.IntegrityError: NOT NULL constraint failed: store_customer.email
- c++ - 在命令行上生成损坏的名称
- python - 如何调用熊猫数据框应用函数返回两个变量
- javascript - SVG 文件未加载到导航栏 - 不确定原因是什么。(HTML、CSS、BOOTSTRAP、JS、SVG)