简体   繁体   中英

Cannot install GDAL on docker container

I need to install the latest version of gdal on another docker image. I cant run the osgeo/gdal container separately, because i need the python bindings.

When i run the next code in 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

I get the next error:

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

Can someone please help.

As you've already noticed, the version available via apt(-get) is <6 which explains the error. One way around it is to compile PROJ from source. For instance:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM