CircleCI-Public / CircleCI-Public/cimg-postgres

Bug Report: PGDATA: /dev/shm/pgdata/data prevent cimg/postgres:15.4 from starting

Open
#146 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Dockerfile
Stars
10
Forks
27
PR merge metrics
No merged PRs in 30d

Description

---

**Describe the bug**
PGDATA: /dev/shm/pgdata/data prevent cimg/postgres:15.4 from starting here is the output from the step

```
********************************************************************************
WARNING: POSTGRES_HOST_AUTH_METHOD has been set to "trust". This will allow
anyone with access to the Postgres port to access your database without
a password, even if POSTGRES_PASSWORD is set. See PostgreSQL
documentation about "trust":
https://www.postgresql.org/docs/current/auth-trust.html
In Docker's default configuration, this is effectively any other
container on the same system.

It is not recommended to use POSTGRES_HOST_AUTH_METHOD=trust. Replace
it with "-e POSTGRES_PASSWORD=password" instead to set a password in
"docker run".
********************************************************************************
could not change directory to "/home/circleci/project": Permission denied
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /dev/shm/pgdata/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
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.

Success. You can now start the database server using:

pg_ctl -D /dev/shm/pgdata/data -l logfile start

could not change directory to "/home/circleci/project": Permission denied
waiting for server to start....2025-10-03 03:45:54.969 UTC [104] LOG: starting PostgreSQL 15.14 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, 64-bit
2025-10-03 03:45:54.970 UTC [104] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2025-10-03 03:45:54.972 UTC [107] LOG: database system was shut down at 2025-10-03 03:45:54 UTC
2025-10-03 03:45:54.977 UTC [104] LOG: database system is ready to accept connections
done
server started
could not change directory to "/home/circleci/project": Permission denied
could not change directory to "/home/circleci/project": Permission denied
CREATE DATABASE

/usr/local/bin/docker-entrypoint.sh: running /docker-entrypoint-initdb.d/pg_cron.sh
shared_buffers = 512MB
max_connections = 200
max_prepared_transactions = 200
max_locks_per_transaction = 512
max_pred_locks_per_transaction = 256
listen_addresses = '*'
shared_preload_libraries = 'pg_cron'
cron.database_name = 'circle_test'
grep: /var/lib/postgresql/data/postgresql.conf: No such file or directory
/docker-entrypoint-initdb.d/pg_cron.sh: line 18: /var/lib/postgresql/data/postgresql.conf: No such file or directory
cat: /var/lib/postgresql/data/postgresql.conf: No such file or directory
cat: /var/lib/postgresql/data/postgresql.conf: No such file or directory

exited with error (exited with 1)
```

**To Reproduce**
Please provide steps to reproduce the behavior, such as a sample job or config file.

```
version: 2.1
jobs:
test:
docker:
# TODO: Add matrix builds
- image: cimg/python:3.13.5
environment:
STOP_CELERY_FOR_TESTS: True
DATABASE_URL: psql://root:secret@localhost/circle_test
PYTHONWARNINGS: default
- image: cimg/postgres:15.14
environment:
POSTGRES_PASSWORD: secret
POSTGRES_USER: root
PGDATA: /dev/shm/pgdata/data
steps:
- run: python --version > python_version
```

**Expected behavior**
postgres service runs

**Workarounds**
remove PGDATA env var, but our tests go from running in 20 minutes to 30.

Contributor guide

Open the contributing guide

Research direction

Reproduce the provided CircleCI job using cimg/postgres:15.14 and PGDATA=/dev/shm/pgdata/data. Then inspect /docker-entrypoint-initdb.d/pg_cron.sh and how it locates postgresql.conf when PGDATA is customized. Done means the PostgreSQL service starts successfully with this configuration and the pg_cron initialization completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, postgresql
Domain
databases, devops
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.