我正在尝试设置Docker和geodjagno。在docker-compose up上,我遇到以下错误:

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal", "GDAL", "gdal2.2.0", "gdal2.1.0", "gdal2.0.0", "gdal1.11.0", "gdal1.10.0", "gdal1.9.0"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

GDAL是可以在此图像中找到的库wooyek/geodjango
Docker文件
 FROM wooyek/geodjango
 ENV PYTHONUNBUFFERED 1
 RUN mkdir /code
 WORKDIR /code
 ADD requirements.txt /code/
 RUN pip install -r requirements.txt
 ADD . /code/

docker 组成
services:

  web:
    build: .
    container_name: web
    command: python3 manage.py runserver 0.0.0.0:8000
    volumes:
      - .:/code
    ports:
      - "8000:8000"
    depends_on:
      - db

  db:
    image: mdillon/postgis
    #command: -e POSTGRES_USER=johndoe -e POSTGRES_PASSWORD=myfakedata -e POSTGRES_DB=myfakedata library/postgres
    environment:
      - POSTGRES_USER=johndoe
      - POSTGRES_PASSWORD=myfakedata
      - POSTGRES_DB=myfakedata
    ports:
      - "5435:5432"


  adminer:
    image: adminer
    restart: always
    ports:
      - 8080:8080

最佳答案

尝试在Dockerfile中添加以下内容:

RUN apt-get update &&\
    apt-get install -y binutils libproj-dev gdal-bin

关于docker - 如何在Docker中添加GDAL,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/52396635/

10-09 02:09