无法在 docker 容器上安装 GDAL

Cannot install GDAL on docker container

我需要在另一个 docker 图像上安装最新版本的 gdal。我不能单独 运行 osgeo/gdal 容器,因为我需要 python 绑定。

当我运行 docker中的下一个代码

FROM apache/airflow:2.2.3-python3.9
USER root

RUN apt install update
RUN apt-get install -y \
         build-essential \
         python-all-dev \
         python-is-python3 \
         libproj-dev \
         libpq-dev \
         libgeos-dev \
         wget


RUN wget http://download.osgeo.org/gdal/3.4.0/gdal-3.4.0.tar.gz
RUN tar xvfz gdal-3.4.0.tar.gz
WORKDIR ./gdal-3.4.0
RUN ./configure --with-python --with-pg --with-geos
RUN make
RUN make install
RUN ldconfig

我收到下一个错误:

configure: error: PROJ 6 symbols not found
The command '/bin/bash -o pipefail -o errexit -o nounset -o nolog -c ./configure --with-python --with-pg --with-geos' returned a non-zero code: 1

有人可以帮忙吗。

正如您已经注意到的,通过 apt(-get) 可用的版本是 <6,它解释了错误。一种解决方法是从源代码编译 PROJ。例如:

FROM apache/airflow:2.2.3-python3.9

USER root
RUN apt-get update && \
    apt-get install -y \
    build-essential \
    python-all-dev \
    libpq-dev \
    libgeos-dev \
    wget \
    curl \
    sqlite3 \
    cmake \
    libtiff-dev \
    libsqlite3-dev \
    libcurl4-openssl-dev \
    pkg-config


# This is just an example with hard-coded paths/uris and no cleanup...
RUN curl https://download.osgeo.org/proj/proj-8.2.1.tar.gz | tar -xz &&\
    cd proj-8.2.1 &&\
    mkdir build &&\
    cd build && \
    cmake .. &&\
    make && \
    make install

RUN wget http://download.osgeo.org/gdal/3.4.0/gdal-3.4.0.tar.gz
RUN tar xvfz gdal-3.4.0.tar.gz
WORKDIR ./gdal-3.4.0
RUN ./configure --with-python --with-pg --with-geos &&\
    make && \
    make install && \
    ldconfig