10

I am trying to setup Docker and geodjagno. Upon docker-compose up I have this following error:

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 is a library that can be found in this image wooyek/geodjango

Dockerfile

 FROM wooyek/geodjango
 ENV PYTHONUNBUFFERED 1
 RUN mkdir /code
 WORKDIR /code
 ADD requirements.txt /code/
 RUN pip install -r requirements.txt
 ADD . /code/

docker-compose

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
jsiot
  • 126
  • 4
  • 16
Papouche Guinslyzinho
  • 5,277
  • 14
  • 58
  • 101

4 Answers4

21

Try adding the following in your Dockerfile:

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

You can add the following to your docker file

# Install GDAL dependencies
RUN apt-get install -y libgdal-dev g++ --no-install-recommends && \
    apt-get clean -y



# Update C env vars so compiler can find gdal
ENV CPLUS_INCLUDE_PATH=/usr/include/gdal
ENV C_INCLUDE_PATH=/usr/include/gdal
theSekyi
  • 462
  • 2
  • 6
  • 23
1

If you use alpine Docker image :

RUN apk --no-cache add ca-certificates tzdata
RUN apk add --no-cache --repository http://dl-cdn.alpinelinux.org/alpine/edge/testing gdal
eclaude
  • 846
  • 14
  • 30
0

I had the same issue for a long time only to realize my release pipeline was building from the wrong Dockerfile. Doh.

Anyways we were able to fix the issue by adding this line to our Dockerfile. It's based off the Django GIS docs found here.


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

FYI we're using the python:3.8-slim image.

qosha
  • 11
  • 1