I’m deploying an application (on docker) that is totally dependent on sf
but I’m having trouble loading it into docker :
FROM rocker/shiny
#Make a directory in the container
RUN mkdir /home/shiny-app
RUN R -e "install.packages('sf')"
RUN R -e "library('sf')"
COPY . /home/shiny-app/
This is the error message I received. I have no idea what caused this error. Probably GDAL?
I need help to solve this problem.
2
Answers
When you want to add R packages to a new OS running R, you need to be aware of any underlying OS packages that are required. In this case, reading
sf
‘sDESCRIPTION
, we seeIt’s not always intuitive how to know what these labels mean. One place you might look for a hint about this is Posit’s Package Manager, which lists the following OS requirements on Ubuntu 22.04 (on which
rocker/shiny
is based).Many of those are likely already present.
First, let me reproduce the problem:
Through experience, I know that Jammy (22.04) needs these packages for R’s
sf
package, add these lines somewhere in yourDockerfile
:Notes:
apt
andinstall.packages(..)
commands are up to you.rm -rf
command).It now works:
You may want to look into the geospatial docker images, e.g. the one found here: https://github.com/rocker-org/rocker-versioned2/blob/master/dockerfiles/geospatial_4.3.3.Dockerfile
Based on rocker, these contain package sf.