Extension "postgis" is not available even in postgis/postgis Docker image. [Django]

I'm building Docker image for my Django app. Tried both latest ubuntu and postgis/postgis base images with the following build step:

RUN apt-get install --no-install-recommends -y --no-install-recommends  \
    python3 python3-pip wget gcc postgresql-15-postgis-3 postgresql-15-postgis-3-scripts \
    libnewlib-arm-none-eabi avr-libc git libpq-dev libssl-dev libc6 gdal-bin

When I run pytest I get the following error:

self = <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x7fa258c06e20>
sql = 'CREATE EXTENSION IF NOT EXISTS postgis', params = None
ignored_wrapper_args = (False, {'connection': <django.contrib.gis.db.backends.postgis.base.DatabaseWrapper object at 0x7fa265a6f3a0>, 'cursor': <django.db.backends.postgresql.base.CursorDebugWrapper object at 0x7fa258c06e20>})

    def _execute(self, sql, params, *ignored_wrapper_args):
        self.db.validate_no_broken_transaction()
        with self.db.wrap_database_errors:
            if params is None:
                # params default might be backend specific.
>               return self.cursor.execute(sql)
E               django.db.utils.NotSupportedError: extension "postgis" is not available
E               DETAIL:  Could not open extension control file "/usr/share/postgresql/15/extension/postgis.control": No such file or directory.
E               HINT:  The extension must first be installed on the system where PostgreSQL is running.```
Back to Top