无法打开RPM,正在Dockerfile中跳过

guicsvcw  于 2023-03-29  发布在  Docker
关注(0)|答案(1)|浏览(123)

我正在尝试创建一个Dockerfile来构建我们的可重用镜像。

FROM crystaltwix/centos-mono
MAINTAINER crystaltwix

ADD ./rpms/MyRpm.rpm ./rpms
RUN yum --nogpgcheck localinstall ./rpms/MyRpm.rpm

我得到一个错误

Cannot open: ./rpms/Myrpm.rpm.  Skipping.

我不明白的是,如果我在容器中运行镜像,为什么它不工作:

sudo docker run -i -t -v /home/crystaltwix/projects/rpms:/opt/rpms crystaltwix/centos-mono /bin/bash

然后在容器的shell中,我执行相同的命令:

yum --nogpgcheck localinstall ./rpms/MyRpm.rpm

这很好用。只是在我的Dockerfile中不起作用。我是否错过了Dockerfile构建镜像的方式的一些特定内容?

w6lpcovy

w6lpcovy1#

来自https://docs.docker.com/reference/builder/#add:If <src> is any other kind of file, it is copied individually along with its metadata. In this case, if <dest> ends with a trailing slash /, it will be considered a directory and the contents of <src> will be written at <dest>/base(<src>).
ADD ./rpms/MyRpm.rpm ./rpms会导致./rpms成为MyRpm.rpm文件。请改用ADD ./rpms/MyRpm.rpm ./rpms/

相关问题