0

I am creating a docker image via dockerfile.

...
RUN dnf install -y cpan perl perl-core perl-App-cpanminus make
RUN cpan Config::Properties
...

I require to install a CPAN library (Config::Properties) but my system is behind the proxy and therefore system is unable to install it.

Fetching with HTTP::Tiny:
http://www.cpan.org/authors/01mailrc.txt.gz
HTTP::Tiny failed with an internal error: Could not connect to 'www.cpan.org:80': Connection timed out

I found that this can be fixed by configuring a proxy for CPAN, like (https://stackoverflow.com/a/46859266/1690588)

$ cpan  # to open cpan shell
  cpan[1]> o conf http_proxy "host:port"
  cpan[2]> o conf commit
  cpan[3]> q

BUT how can I do this inside dockerfile. Please suggest. Thank you!

1 Answer 1

0

Not able to find a solution. So I added a hack to achieve this -

  • performed the same operation on my host machine (installed cpan)

  • copy cpan configuration file from host /root/.cpan/CPAN/MyConfig.pm

  • and pasted in parallel to my Dockerfile

  • then added code in my Dockerfile to copy this file into the image so that I can fix the above issue

    ...
    RUN cpan
    COPY MyConfig.pm /root/.cpan/CPAN/MyConfig.pm
    RUN cpan Config::Properties
    ...
    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.