Installing Shapely on Alpine docker


I struggled with the same issue (not working with Django and PostGres database though).

Finally I managed to tackle this with the solution of Amir. I added the repositories from according to The part that was crucial was running geos-config after the implementation of geos-dev and geos. After this I installed the python modules, including pandas. At the clean up section .build-deps is skipped as said.

This is the part of my Dockerfile that did the trick:

RUN apk --update add build-base libxslt-dev

RUN apk add --virtual .build-deps \
        --repository \
        --repository \
        gcc libc-dev geos-dev geos && \
    runDeps="$(scanelf --needed --nobanner --recursive /usr/local \
    | awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
    | xargs -r apk info --installed \
    | sort -u)" && \
    apk add --virtual .rundeps $runDeps

RUN geos-config --cflags

RUN pip install --disable-pip-version-check -r requirements.txt

RUN apk del build-base python3-dev && \
    rm -rf /var/cache/apk/*

By the way, I also tried the solution provided on But this didn't work out for me.