dockerproxycpan

dockerfile - cpan proxy configuration


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!


Solution

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