Docker Build Error - Distribution of App::cpanminus

Dear Docker Support Team,

I am currently facing an issue while attempting to build a Docker container on my Ubuntu 20.04.6 LTS machine. The Dockerfile I am using includes instructions to install some Perl dependencies, including the distribution “App::cpanminus.”

Here is the command I’m using for the Docker build:

sudo docker build ./ --network=host --build-arg version=2018.2 --build-arg date_created=1110 -t petalinux-182-ubuntu:test

Unfortunately, during the build process, I encountered an error related to the distribution of “App::cpanminus,” despite having manually installed “cpan” on my Ubuntu machine. This error has been quite challenging to resolve, and I would appreciate your assistance in finding a solution.

To provide you with more context, here are the specific details of the error:

I have already taken the following steps to troubleshoot the issue:

  1. Manually installed “cpan” on my Ubuntu machine.

Despite these efforts, the issue persists, and I am unable to successfully complete the Docker build process.

I kindly request your guidance and assistance in resolving this issue. If you could provide instructions on how to address the “App::cpanminus” distribution error or any additional troubleshooting steps, it would be greatly appreciated.

Welcome. This is a community forum and most of us are just community members, but you don’t actually need the Docker support team.

Since you are building a image, dependencies must be installed in the image, not on your Ubuntu machine.

Also please, avoid sharing screenshots showing texts and share codes as code blocks. More information about formatting: How to format your forum posts

Hi @rimelek,

Below is the command and the error generated at the end. How can I fix it? Please provide the procedure.

hp@hp:~/petalinux-v2018.2-docker/petalinux-182-docker-ubuntu$ sudo docker build ./ --network=host --build-arg version=2018.2 --build-arg date_created=1110 -t petalinux-182-ubuntu:test
[+] Building 1170.6s (16/25)                                                                                                    docker:default
 => [internal] load .dockerignore                                                                                                         0.0s
 => => transferring context: 2B                                                                                                           0.0s
 => [internal] load build definition from Dockerfile                                                                                      0.0s
 => => transferring dockerfile: 3.97kB                                                                                                    0.0s
 => [internal] load metadata for docker.io/library/ubuntu:16.04                                                                           5.6s
 => [ 1/21] FROM docker.io/library/ubuntu:16.04@sha256:1f1a2d56de1d604801a9671f301190704c25d604a416f59e03c04f5c6ffee0d6                 143.2s
 => => resolve docker.io/library/ubuntu:16.04@sha256:1f1a2d56de1d604801a9671f301190704c25d604a416f59e03c04f5c6ffee0d6                     0.0s
 => => sha256:1f1a2d56de1d604801a9671f301190704c25d604a416f59e03c04f5c6ffee0d6 1.42kB / 1.42kB                                            0.0s
 => => sha256:a3785f78ab8547ae2710c89e627783cfa7ee7824d3468cae6835c9f4eae23ff7 1.15kB / 1.15kB                                            0.0s
 => => sha256:b6f50765242581c887ff1acc2511fa2d885c52d8fb3ac8c4bba131fd86567f2e 3.36kB / 3.36kB                                            0.0s
 => => sha256:58690f9b18fca6469a14da4e212c96849469f9b1be6661d2342a4bf01774aa50 46.50MB / 46.50MB                                        141.7s
 => => sha256:b51569e7c50720acf6860327847fe342a1afbe148d24c529fb81df105e3eed01 857B / 857B                                                0.5s
 => => sha256:da8ef40b9ecabc2679fe2419957220c0272a965c5cf7e0269fa1aeeb8c56f2e1 528B / 528B                                                0.5s
 => => sha256:fb15d46c38dcd1ea0b1990006c3366ecd10c79d374f341687eb2cb23a2c8672e 170B / 170B                                                1.0s
 => => extracting sha256:58690f9b18fca6469a14da4e212c96849469f9b1be6661d2342a4bf01774aa50                                                 1.4s
 => => extracting sha256:b51569e7c50720acf6860327847fe342a1afbe148d24c529fb81df105e3eed01                                                 0.0s
 => => extracting sha256:da8ef40b9ecabc2679fe2419957220c0272a965c5cf7e0269fa1aeeb8c56f2e1                                                 0.0s
 => => extracting sha256:fb15d46c38dcd1ea0b1990006c3366ecd10c79d374f341687eb2cb23a2c8672e                                                 0.0s
 => [internal] load build context                                                                                                        39.6s
 => => transferring context: 6.71GB                                                                                                      39.6s
 => [ 2/21] RUN dpkg --add-architecture i386                                                                                              0.4s
 => [ 3/21] RUN apt-get update -y && apt-get clean all                                                                                  136.7s
 => [ 4/21] RUN apt-get install -y sudo iputils-ping                                                                                     14.0s
 => [ 5/21] RUN echo "%sudo ALL=(ALL:ALL) ALL" >> /etc/sudoers                                                                            0.1s
 => [ 6/21] RUN echo "%sudo ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers                                                                       0.1s
 => [ 7/21] RUN apt-get install -y tofrodos iproute2 gawk xvfb gcc-4.8 wget build-essential checkinstall libreadline-gplv2-dev  libncu  706.6s
 => [ 8/21] RUN cd /usr/src && wget https://www.python.org/ftp/python/3.4.5/Python-3.4.5.tgz && tar xzf Python-3.4.5.tgz && rm -f Pyth  161.2s
 => [ 9/21] RUN mkdir -p /proj/petalinux /tools/xgs/perl /proj/petalinux/petalinux-v2018.2 /proj/petalinux/petalinux-v2018.2_bsps         0.1s
 => [10/21] ADD plnx_installer.pl /proj/petalinux/petalinux-v2018.2                                                                       0.0s
 => [11/21] ADD default.env /tmp                                                                                                          0.0s
 => ERROR [12/21] RUN wget -O - http://cpanmin.us | perl - App::cpanminus                                                                 2.6s
------
 > [12/21] RUN wget -O - http://cpanmin.us | perl - App::cpanminus:
0.036 --2023-10-04 17:57:32--  http://cpanmin.us/
0.036 Resolving cpanmin.us (cpanmin.us)... 151.101.66.217, 151.101.2.217, 151.101.194.217, ...
1.363 Connecting to cpanmin.us (cpanmin.us)|151.101.66.217|:80... connected.
1.408 HTTP request sent, awaiting response... 200 OK
1.945 Length: 302419 (295K) [text/plain]
1.945 Saving to: 'STDOUT'
1.945 
1.945      0K .......... .......... .......... .......... .......... 16% 1.02M 0s
1.995     50K .......... .......... .......... .......... .......... 33% 1.55M 0s
2.033    100K .......... .......... .......... .......... .......... 50%  448K 0s
2.139    150K .......... .......... .......... .......... .......... 67%  480K 0s
2.240    200K .......... .......... .......... .......... .......... 84%  473K 0s
2.346    250K .......... .......... .......... .......... .....     100%  492K=0.5s
2.438 
2.438 2023-10-04 17:57:34 (599 KB/s) - written to stdout [302419/302419]
2.438 
2.572 ! Finding App::cpanminus on cpanmetadb failed.
2.620 ! cannot open file '/root/.cpanm/sources/http%www.cpan.org/02packages.details.txt.gz': No such file or directory opening compressed index
2.620 ! Couldn't find module or a distribution App::cpanminus
------
Dockerfile:46
--------------------
  44 |     ADD default.env /tmp
  45 |     
  46 | >>> RUN wget -O - http://cpanmin.us | perl - App::cpanminus
  47 |     
  48 |     ADD File-Tail-1.3.tar.gz /tmp
--------------------
ERROR: failed to solve: process "/bin/sh -c wget -O - http://cpanmin.us | perl - App::cpanminus" did not complete successfully: exit code: 1

Sorry, but I can’t help you with perl.You need to install all the dependencies in the image before you run the perl command. How you can install a perl module properly I don’t know.

Also you shared the output of the build command which shows only a part of the commands you run during the build. Sharing a Dockerfile would help everyone to see what you are trying to do more clearly.