Replies: 5 comments 7 replies
-
I can't reproduce, so I'd suggest checking your logs for any clues to what's going on; here's the relevant snippet from my logs:
|
Beta Was this translation helpful? Give feedback.
-
This is the log if I remove the initializing script: version: "3.7"
services:
db:
image: postgres:16.6-alpine3.20
restart: always
environment:
- POSTGRES_DB=db
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- PGPORT=${POSTGRES_PORT}
ports:
- ${POSTGRES_PORT}:${POSTGRES_PORT}
volumes:
- ./my-db:/var/lib/postgresql/data
# - ./db-seed.sql:/docker-entrypoint-initdb.d/seed.sql => commented out
command: postgres -c 'log_statement=all' db-1 | 2025-02-26T20:22:45.702572525Z The files belonging to this database system will be owned by user "postgres".
db-1 | 2025-02-26T20:22:45.702592733Z This user must also own the server process.
db-1 | 2025-02-26T20:22:45.702594108Z
db-1 | 2025-02-26T20:22:45.702612400Z The database cluster will be initialized with locale "en_US.utf8".
db-1 | 2025-02-26T20:22:45.702614192Z The default database encoding has accordingly been set to "UTF8".
db-1 | 2025-02-26T20:22:45.702615150Z The default text search configuration will be set to "english".
db-1 | 2025-02-26T20:22:45.702616067Z
db-1 | 2025-02-26T20:22:45.702616817Z Data page checksums are disabled.
db-1 | 2025-02-26T20:22:45.702617567Z
db-1 | 2025-02-26T20:22:45.703815858Z fixing permissions on existing directory /var/lib/postgresql/data ... ok
db-1 | 2025-02-26T20:22:45.734508567Z creating subdirectories ... ok
db-1 | 2025-02-26T20:22:45.737698150Z selecting dynamic shared memory implementation ... posix
db-1 | 2025-02-26T20:22:45.756451942Z selecting default max_connections ... 100
db-1 | 2025-02-26T20:22:45.774351025Z selecting default shared_buffers ... 128MB
db-1 | 2025-02-26T20:22:45.790905608Z selecting default time zone ... UTC
db-1 | 2025-02-26T20:22:45.800790358Z creating configuration files ... ok
db-1 | 2025-02-26T20:22:49.143710152Z running bootstrap script ... ok
db-1 | 2025-02-26T20:22:49.465694652Z sh: locale: not found
db-1 | 2025-02-26T20:22:49.465749818Z 2025-02-26 20:22:49.465 UTC [35] WARNING: no usable system locales were found
db-1 | 2025-02-26T20:22:53.751759779Z performing post-bootstrap initialization ... ok
db-1 | 2025-02-26T20:22:58.058551197Z syncing data to disk ... ok
db-1 | 2025-02-26T20:22:58.058568614Z
db-1 | 2025-02-26T20:22:58.058569864Z
db-1 | 2025-02-26T20:22:58.058570656Z Success. You can now start the database server using:
db-1 | 2025-02-26T20:22:58.058571489Z
db-1 | 2025-02-26T20:22:58.058572239Z pg_ctl -D /var/lib/postgresql/data -l logfile start
db-1 | 2025-02-26T20:22:58.058572947Z
db-1 | 2025-02-26T20:22:58.058591489Z initdb: warning: enabling "trust" authentication for local connections
db-1 | 2025-02-26T20:22:58.058596156Z initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.
db-1 | 2025-02-26T20:22:58.099101989Z waiting for server to start....2025-02-26 20:22:58.099 UTC [41] LOG: starting PostgreSQL 16.6 on aarch64-unknown-linux-musl, compiled by gcc (Alpine 13.2.1_git20240309) 13.2.1 20240309, 64-bit
db-1 | 2025-02-26T20:22:58.099963364Z 2025-02-26 20:22:58.099 UTC [41] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
db-1 | 2025-02-26T20:22:58.114036323Z 2025-02-26 20:22:58.113 UTC [44] LOG: database system was shut down at 2025-02-26 20:22:53 UTC
db-1 | 2025-02-26T20:22:58.141649364Z 2025-02-26 20:22:58.141 UTC [41] LOG: database system is ready to accept connections
db-1 | 2025-02-26T20:22:58.178670239Z done
db-1 | 2025-02-26T20:22:58.178681906Z server started
db-1 | 2025-02-26T20:22:58.221855614Z 2025-02-26 20:22:58.221 UTC [50] LOG: statement: SELECT 1 FROM pg_database WHERE datname = 'db' ;
db-1 | 2025-02-26T20:22:58.269235114Z 2025-02-26 20:22:58.269 UTC [52] LOG: statement: CREATE DATABASE "test_db" ; The biggest different between those is that I am getting the error message |
Beta Was this translation helpful? Give feedback.
-
Oh, I think version: "3.7"
services:
db:
image: postgres:16.6-alpine3.20
restart: always
environment:
- POSTGRES_DB=db
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
ports:
- ${POSTGRES_PORT}:5432
volumes:
- ./my-db:/var/lib/postgresql/data
- ./db-seed.sql:/docker-entrypoint-initdb.d/seed.sql
command: postgres -c 'log_statement=all' |
Beta Was this translation helpful? Give feedback.
-
What happens if you comment out |
Beta Was this translation helpful? Give feedback.
-
This is resolved automatically, but I am not sure how. Perhaps just needed to restart my computer... Thanks again for everyone's time, help and support! |
Beta Was this translation helpful? Give feedback.
-
Hello, I am encountering a problem where if I bind my volume to /var/lib/postgresql/data, then my initializing script won't execute even if the folder does not exists in the beginning.
image:
postgres:16.6-alpine3.20
Here's what my docker compose
My initializing sql is just to create the database
I am trying to have the initializing sql to run when the my-db folder does not exist.
When I run with one or another then the behavior is as expected, however, if I have both together (and that my my-db folder is deleted and volumes are destroyed) then the initializing sql won't run.
I have tried same thing in postgres 12 and it worked.
Is this an issue with version 16?
Beta Was this translation helpful? Give feedback.
All reactions