我正在尝试创建一个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构建图像的方式?提前谢谢。
答案 0 :(得分:1)
来自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/
。