如何使用Dockerfile安装openssl?

问题描述 投票:0回答:1

我正在为需要 OpenSSL 1.1.1 而不是默认 3.0 的应用程序创建 docker 映像

我在 Dockerfile 中添加了以下命令

RUN wget -O - https://www.openssl.org/source/openssl-1.1.1u.tar.gz | tar zxf -
RUN cd openssl-1.1.1u 
RUN ./config --prefix=/usr/local

但是,

RUN ./config --prefix=/usr/local
行在构建图像期间抛出以下错误。

错误:buildx 失败:错误:无法解决:进程“/bin/sh -c ./config --prefix=/usr/local”未成功完成:退出代码:127

如何修复此错误?

docker openssl dockerfile docker-build buildx
1个回答
0
投票

每个 RUN 命令都是单独的,因此 cd 不会在它们之间持续存在;你需要做类似的事情:

RUN wget -O - https://www.openssl.org/source/openssl-1.1.1u.tar.gz | tar zxf -
RUN cd openssl-1.1.1u; ./config --prefix=/usr/local

此外,每个 RUN 命令都会在生成的 docker 镜像中创建一个新层;如果您想最终得到较小的图像,特别是如果您想清理文件,您可能需要进一步组合它们:

RUN wget -O - https://www.openssl.org/source/openssl-1.1.1u.tar.gz | tar zxf -; \
    cd openssl-1.1.1u; \
    ./config --prefix=/usr/local

(清理文件仅在同一层中完成时才真正删除它们;否则,文件仍然存在,只是标记为已删除)

© www.soinside.com 2019 - 2024. All rights reserved.