Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add GDAL in docker

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
like image 481
Papouche Guinslyzinho Avatar asked Sep 19 '18 01:09

Papouche Guinslyzinho


2 Answers

Try adding the following in your Dockerfile:

RUN apt-get update &&\
    apt-get install -y binutils libproj-dev gdal-bin
like image 175
Michael Paragios Avatar answered Sep 28 '22 06:09

Michael Paragios


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
like image 22
theSekyi Avatar answered Sep 28 '22 06:09

theSekyi