Reputation: 1045
I'm using python3.7-slim-buster docker image for my django project. Now I want to use Geo features of django. But it seems I have to install GDAL. So, I do RUN apt-get install gdal and it raises exception "E: Unable to locate package gdal-bin". Here is my docker file:
FROM python:3.7-slim-buster
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
# DB vars
ENV DB_USER_NAME ${DB_USER_NAME}
ENV DB_NAME ${DB_NAME}
ENV DB_HOST ${DB_HOST}
ENV DB_PORT ${DB_PORT}
ENV DB_PASSWORD ${DB_PASSWORD}
ENV DJANGO_SECRET_KEY ${DJANGO_SECRET_KEY}
RUN apt-get install -y gdal-bin python-gdal python3-gdal
RUN ["adduser", "${USER_NAME}", "--disabled-password", "--ingroup", "www-data", "--quiet"]
USER ${USER_NAME}
ADD ${PROJECT_NAME}/ /home/${USER_NAME}/${PROJECT_NAME}
WORKDIR /home/${USER_NAME}/${PROJECT_NAME}
ENV PATH="/home/${USER_NAME}/.local/bin:\${PATH}:/usr/local/python3/bin"
RUN pip install --user -r requirements.txt
CMD python manage.py runserver 0.0.0.0:9000
#CMD gunicorn ${PROJECT_NAME}.wsgi:application --bind 0.0.0.0:8000
EXPOSE 8000
Upvotes: 9
Views: 12790
Reputation: 1301
If you can use other base image, here is one with gdal installed:
FROM osgeo/gdal:ubuntu-small-3.2.0
Upvotes: 5
Reputation: 18578
you need to do the following:
RUN apt-get update
RUN apt-get install -y software-properties-common && apt-get update
RUN apt-get install -y python3.7-dev
RUN add-apt-repository ppa:ubuntugis/ppa && apt-get update
RUN apt-get install -y gdal-bin libgdal-dev
ARG CPLUS_INCLUDE_PATH=/usr/include/gdal
ARG C_INCLUDE_PATH=/usr/include/gdal
RUN pip install GDAL
Upvotes: 5
Reputation: 3378
That's because your image doesn't have repository which contain gdal-bin package. So you have to add repository (you can see the guideline here) and install it:
RUN add-apt-repository ppa:ubuntugis/ppa && apt-get update && apt-get install -y gdal-bin python-gdal python3-gdal
Upvotes: 0