运行 cpanm 时 docker 构建失败

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

在docker容器中,我有一个perl脚本,我需要能够解析json,我试图在我的Dockerfile中为perl安装

CPAN JSON

所以我在我的

Dockerfile

中执行以下操作
FROM centos:7.9.2009
RUN yum install -y cpanm \
      perl \
      perl-App-cpanminus \
      perl-Config-Tiny \
      sudo \
      &&  yum clean all \
      && sudo cpanm install JSON;

但是当我做

docker build
我得到:

#0 41.76 Configuring Test-Simple-1.302195 ... OK
#0 41.95 Building and testing Test-Simple-1.302195 ... OK
#0 68.48 Successfully installed Test-Simple-1.302195
#0 68.59 Building and testing JSON-4.10 ... OK
#0 126.9 Successfully installed JSON-4.10
#0 127.0 2 distributions installed
------
ERROR: failed to solve: executor failed running [/bin/sh -c yum install -y cpanm     perl     perl-App-cpanminus     perl-Config-Tiny     sudo     &&  yum clean all     && sudo cpanm install JSON;]: exit code: 1

这里有什么问题?

docker perl dockerfile cpan cpanm
1个回答
0
投票

问题是

cpanm
首先无法安装。 运行
docker run -it centos:7.9.2009 /bin/bash
并在容器中执行
yum install -y cpanm
。 我得到:

没有可用的 cpanm 软件包。
错误:无事可做

当我运行

yum install -y cpanm perl sudo perl-App-cpanminus
然后运行
echo $?
时,返回结果是
0
,因为它确实安装了其他软件包。

我怀疑问题在于包名称不是

capnm
而是
perl-CPAN
。请注意,包名称的大小写很重要。

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