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.

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/shinyis 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
sfpackage, add these lines somewhere in yourDockerfile:Notes:
aptandinstall.packages(..)commands are up to you.rm -rfcommand).It now works: