无法在Dockerfile中安装软件包[E:子过程/usr/bin/dpkg返回错误代码(1)]
我正在尝试在Ubuntu 16.04容器中安装一个私人软件包。为此,我使用dockerfile中的以下行来构建使用基本图像ubuntu 16.04的图像,其中nf
是一个参数设置为各种软件包名称(不包括存储库地址):
FROM ubuntu:16.04
ENTRYPOINT ["/sbin/init"]
SHELL ["/bin/bash", "-c"]
ARG nf
RUN touch /etc/apt/sources.list.d/cinar.list
RUN echo -e $"<repository addresses are here>" >> /etc/apt/sources.list.d/cinar.list
RUN apt-get update
RUN apt-get install -y $nf
最后一行结果带有以下错误:
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/bash -c apt-get install -y $nf' returned a non-zero code: 100
但是,当我从dockerfile删除此行并构建图像时,然后进入容器内并使用命令apt -get install -y packagename
,此错误不会发生。由于我正在执行自动化任务,并且无法在容器上手动安装软件包,因此我将不胜感激。我已经尝试了列出的解决方案在这里/a>,它们似乎都没有用。
I am trying to install a private package inside an Ubuntu 16.04 container. To do this, I am using the following line in a Dockerfile to build an image with base image Ubuntu 16.04 where nf
is an argument set to various package names (repository addresses are not included):
FROM ubuntu:16.04
ENTRYPOINT ["/sbin/init"]
SHELL ["/bin/bash", "-c"]
ARG nf
RUN touch /etc/apt/sources.list.d/cinar.list
RUN echo -e quot;<repository addresses are here>" >> /etc/apt/sources.list.d/cinar.list
RUN apt-get update
RUN apt-get install -y $nf
The last line results with the following error:
E: Sub-process /usr/bin/dpkg returned an error code (1)
The command '/bin/bash -c apt-get install -y $nf' returned a non-zero code: 100
However, when I remove this line from the Dockerfile and build the image, then go inside the container and use the command apt-get install -y packagename
, this error does not occur. I would appreciate any help on this issue since I am doing an automation task and cannot manually install packages on containers. I have tried the solutions listed here, and none of them seems to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在
bash
中,$“ repository-addresses”
与repository-addresses
完全相同。repository-addresses
对于/etc/apt/sources.list.d/gh.list中的条目无效,也不是有效的变量名称。如果您将
repository-addresses
作为build-arg,则应将其重命名为repository_addresses
,并将其与以下方式一起使用:In
bash
,$"repository-addresses"
is exactly the same asrepository-addresses
.repository-addresses
is not valid for entries in /etc/apt/sources.list.d/*.list, nor is it a valid variable name.If you have
repository-addresses
as build-arg, you should rename it torepository_addresses
and use it with :