Init script changes don't persist #1170
Replies: 4 comments
-
Yeah not sure why the init script isn't actually doing the Also tried swapping the |
Beta Was this translation helpful? Give feedback.
-
I have the same issue. Create a schema in the init file and it's not created in the container when it runs. Only Create Database works. |
Beta Was this translation helpful? Give feedback.
This comment has been minimized.
This comment has been minimized.
-
I'm not sure what the difference between your Dockerfile and the PostGIS Dockerfiles is, because they are working over there. https://github.com/postgis/docker-postgis/tree/4b53c954472c548c6d63e833404952b6bfb6942a/11-3.3 My guess is that it might be related to postgres background threads that don't quite finish with just a single FROM postgres:11-bullseye
#postgres:11 no longer works as the Debian Stretch PostgreSQL repos are no longer available
RUN set -e; \
apt-get update; \
apt-get install -y postgis postgresql-11-postgis-3; \
rm -rf /var/lib/apt/lists/*
RUN set -e; echo 'CREATE EXTENSION IF NOT EXISTS "postgis";' | tee /docker-entrypoint-initdb.d/postgis.sql $ docker build .
...
Successfully built 5f98ea5a4547
$ docker run -it --rm --name pg -e POSTGRES_PASSWORD=admin 5f98ea5a4547
$ docker exec -it pg psql -U postgres
psql (15.1 (Debian 15.1-1.pgdg110+1), server 11.18 (Debian 11.18-1.pgdg110+1))
Type "help" for help.
postgres=# SELECT PostGIS_version();
postgis_version
---------------------------------------
3.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row) (They have some ~5 month old PostgeSQL 11 with PostGIS 2.5 images that might work for you: https://hub.docker.com/r/postgis/postgis/tags?page=1&name=11-2.5) |
Beta Was this translation helpful? Give feedback.
-
I am working to create a customized
postgresql
image withpostgis
plugin. Following are the contents of docker fileContents of
enable_gis.sql
are as followsplace both files in same folder and build using following command
sudo docker build -t postgis:11-2.5 .
Then create following
docker-compose.yml
fileNow when you spin-up container using docker compose, following output will be shown
Clearly showing that
enable_gis.sql
is called andCREATE EXTENSION
as response, but when I execute SQL commandSELECT PostGIS_version();
on this server, it return error the function is unknown.Now if I execute the command
CREATE EXTENSION IF NOT EXISTS postgis;
then this plugin will be enabled and will start working fine.My Question is why startup script changes are not persistent, they seem to executed successfully but somehow there changes are not saved.
For easy debugging the docker container is already pushed at
ssilhr/postgis:11-2.5
I need PostgreSQL 11 with PostGIS 2.5, so version upgrade is not an option
Beta Was this translation helpful? Give feedback.
All reactions