containers icon indicating copy to clipboard operation
containers copied to clipboard

initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/opt/bitnami/postgresql/bin/initdb"

Open laobel opened this issue 8 months ago • 4 comments

Name and Version

bitnami/postgresql-repmgr

What architecture are you using?

amd64

What steps will reproduce the bug?

How to solve the problem?

Run the following command:

docker network create my-network --driver bridge
docker run --detach --name pg-0 \
  --network my-network \
  --env REPMGR_PARTNER_NODES=pg-0,pg-1 \
  --env REPMGR_NODE_NAME=pg-0 \
  --env REPMGR_NODE_NETWORK_NAME=pg-0 \
  --env REPMGR_PRIMARY_HOST=pg-0 \
  --env REPMGR_PASSWORD=repmgrpass \
  --env POSTGRESQL_PASSWORD=secretpass \
  --env BITNAMI_DEBUG=true \
  bitnami/postgresql-repmgr:latest

Return the following error:

postgresql-repmgr 15:52:05.57 DEBUG ==> Configuring libnss_wrapper...
postgresql-repmgr 15:52:05.59 DEBUG ==> Copying files from /opt/bitnami/postgresql/conf.default to /opt/bitnami/postgresql/conf
postgresql-repmgr 15:52:05.61 INFO  ==> ** Starting PostgreSQL with Replication Manager setup **
postgresql-repmgr 15:52:05.63 INFO  ==> Validating settings in REPMGR_* env vars...
postgresql-repmgr 15:52:05.63 INFO  ==> Validating settings in POSTGRESQL_* env vars..
postgresql-repmgr 15:52:05.64 INFO  ==> Querying all partner nodes for common upstream node...
postgresql-repmgr 15:52:05.76 DEBUG ==> Checking node 'pg-1:5432'...
psql: error: connection to server at "pg-1" (172.18.0.4), port 5432 failed: Connection refused
	Is the server running on that host and accepting TCP/IP connections?
postgresql-repmgr 15:52:06.42 DEBUG ==> Skipping: failed to get primary from the node 'pg-1:5432'!
postgresql-repmgr 15:52:06.43 DEBUG ==> Checking node 'pg-0:5432'...
psql: error: connection to server at "pg-0" (172.18.0.3), port 5432 failed: Connection refused
	Is the server running on that host and accepting TCP/IP connections?
postgresql-repmgr 15:52:06.45 DEBUG ==> Skipping: failed to get primary from the node 'pg-0:5432'!
postgresql-repmgr 15:52:06.46 INFO  ==> There are no nodes with primary role. Assuming the primary role...
postgresql-repmgr 15:52:06.47 INFO  ==> Preparing PostgreSQL configuration...
postgresql-repmgr 15:52:06.47 DEBUG ==> Injecting a new postgresql.conf file...
postgresql-repmgr 15:52:06.47 INFO  ==> postgresql.conf file not detected. Generating it...
postgresql-repmgr 15:52:06.59 DEBUG ==> Injecting a new pg_hba.conf file...
postgresql-repmgr 15:52:06.60 INFO  ==> Preparing repmgr configuration...
postgresql-repmgr 15:52:06.61 DEBUG ==> Node ID: '1000', Rol: 'primary', Primary Node: ':5432'
postgresql-repmgr 15:52:06.62 INFO  ==> Initializing Repmgr...
postgresql-repmgr 15:52:06.63 INFO  ==> Initializing PostgreSQL database...
postgresql-repmgr 15:52:06.63 DEBUG ==> Copying files from /bitnami/postgresql/conf to /opt/bitnami/postgresql/conf
postgresql-repmgr 15:52:06.64 INFO  ==> Custom configuration /opt/bitnami/postgresql/conf/postgresql.conf detected
postgresql-repmgr 15:52:06.64 DEBUG ==> Ensuring expected directories/files exist...
postgresql-repmgr 15:52:06.66 INFO  ==> pg_hba.conf file not detected. Generating it...
postgresql-repmgr 15:52:06.66 INFO  ==> Generating local authentication configuration
popen failure: Cannot allocate memory
initdb: error: program "postgres" is needed by initdb but was not found in the same directory as "/opt/bitnami/postgresql/bin/initdb"

laobel avatar Jun 03 '25 16:06 laobel

We're not able to reproduce the issue, using exactly the same docker run command the container is up and running and we're able to connect from a client:

$ docker network create my-network --driver bridge
$ docker run --detach --name pg-0 \
  --network my-network \
  --env REPMGR_PARTNER_NODES=pg-0,pg-1 \
  --env REPMGR_NODE_NAME=pg-0 \
  --env REPMGR_NODE_NETWORK_NAME=pg-0 \
  --env REPMGR_PRIMARY_HOST=pg-0 \
  --env REPMGR_PASSWORD=repmgrpass \
  --env POSTGRESQL_PASSWORD=secretpass \
  --env BITNAMI_DEBUG=true \
  bitnami/postgresql-repmgr:latest

$ docker ps
CONTAINER ID   IMAGE                              COMMAND                  CREATED              STATUS              PORTS      NAMES
06aca4e0a694   bitnami/postgresql                 "/opt/bitnami/script…"   About a minute ago   Up About a minute   5432/tcp   distracted_moser
1a0d623b37bd   bitnami/postgresql-repmgr:latest   "/opt/bitnami/script…"   3 minutes ago        Up 3 minutes        5432/tcp   pg-0

$ docker run -it --rm --network my-network bitnami/postgresql psql -h pg-0 -U postgres
postgresql 12:57:06.27 INFO  ==>
postgresql 12:57:06.27 INFO  ==> Welcome to the Bitnami postgresql container
postgresql 12:57:06.27 INFO  ==> Subscribe to project updates by watching https://github.com/bitnami/containers
postgresql 12:57:06.27 INFO  ==> Did you know there are enterprise versions of the Bitnami catalog? For enhanced secure software supply chain features, unlimited pulls from Docker, LTS support, or application customization, see Bitnami Premium or Tanzu Application Catalog. See https://www.arrow.com/globalecs/na/vendors/bitnami/ for more information.
postgresql 12:57:06.27 INFO  ==>

Password for user postgres:
psql (17.5)
Type "help" for help.

postgres=# \l
                                                     List of databases
   Name    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | Locale | ICU Rules |   Access privileges
-----------+----------+----------+-----------------+-------------+-------------+--------+-----------+-----------------------
 postgres  | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           |
 repmgr    | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           |
 template0 | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | =c/postgres          +
           |          |          |                 |             |             |        |           | postgres=CTc/postgres
 template1 | postgres | UTF8     | libc            | en_US.UTF-8 | en_US.UTF-8 |        |           | =c/postgres          +
           |          |          |                 |             |             |        |           | postgres=CTc/postgres
(4 rows)

carrodher avatar Jun 04 '25 13:06 carrodher

Thank you very much for your answer. This question appears in some operating systems。Deploy Docker using the following system image can reproduce the issue. system image

laobel avatar Jun 05 '25 17:06 laobel

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] avatar Jun 21 '25 01:06 github-actions[bot]

I have tried many methods but still haven't solved this problem. I have tried reinstalling the system and running it through virtual machines, but the same problem persists. How can I investigate the cause of this problem? Please give me a direction, thank you very much.

laobel avatar Jun 21 '25 05:06 laobel

This Issue has been automatically marked as "stale" because it has not had recent activity (for 15 days). It will be closed if no further activity occurs. Thanks for the feedback.

github-actions[bot] avatar Jul 07 '25 01:07 github-actions[bot]

Due to the lack of activity in the last 5 days since it was marked as "stale", we proceed to close this Issue. Do not hesitate to reopen it later if necessary.

github-actions[bot] avatar Jul 12 '25 01:07 github-actions[bot]