'install.packages('dplyr') in container generates "Warning: unable to access index for repository"

Here is my Dockerfile:

FROM rocker/r-ver:4.0.4
RUN R -e "install.packages('dplyr')"

During image build process it generates error:

> install.packages('dplyr')
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning: unable to access index for repository https://packagemanager.rstudio.com/cran/__linux__/focal/2021-03-30/src/contrib:
  cannot open URL 'https://packagemanager.rstudio.com/cran/__linux__/focal/2021-03-30/src/contrib/PACKAGES'
>
>
Warning message:
package ‘dplyr’ is not available for this version of R

A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-package

I can reproduce the same error by connecting to container CLI.

Is there a fix for it?

Update:

I am running Docker locally on Windows 10 machine. I can connect to https://packagemanager.rstudio.com/cran/__linux__/focal/2021-03-30/src/contrib/PACKAGES on Windows, but when I ping this URL from container I get: Name or service not known. Is this certificate issue? Is there fix for it.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source