# Postgres container failing with initdb error: \`program "postgres" is needed by initdb but was not found\`

**URL:** <https://discuss.circleci.com/t/postgres-container-failing-with-initdb-error-program-postgres-is-needed-by-initdb-but-was-not-found/48470>\
**Category:** Databases\
**Tags:** docker\
**Created:** [June 26, 2023, 2:32am UTC](https://discuss.circleci.com/t/postgres-container-failing-with-initdb-error-program-postgres-is-needed-by-initdb-but-was-not-found/48470 "2023-06-26T02:32:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kelvintaywl](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kelvintaywl/32/28141_2.png) [@kelvintaywl](https://discuss.circleci.com/u/kelvintaywl)\
**Post date:** [June 26, 2023, 2:32am UTC](https://discuss.circleci.com/t/postgres-container-failing-with-initdb-error-program-postgres-is-needed-by-initdb-but-was-not-found/48470/1 "2023-06-26T02:32:37Z")

</div>

As of June 15th 2023, [the official Postgres Docker images](https://hub.docker.com/_/postgres/tags) were published to be based on Debian 12.0 (Bookworm) rather than Debian 11.0 (Bullseye).  
See [Issues · docker-library/postgres · GitHub](https://github.com/docker-library/postgres/issues?q=is%3Aissue+bookworm)

CircleCI Support team has noted some customers seeing the following issues when using the official `postgres` Docker image then:

```plaintext
# error seen when using postgres:13
popen failure: Cannot allocate memory
initdb: error: The program "postgres" is needed by initdb but was not found in the
same directory as "/usr/lib/postgresql/13/bin/initdb".

```

The Docker community (maintainers of the Postgres official image) are aware of the reported issues.  
For folks encountering this error, we recommend try switching to `*-bullseye` images as a workaround:

```diff
- postgres:14
+ postgres:14-bullseye

```

If this still does not solve your issue, you can also try using alternative Postgres images.  
For example, you can consider using [CircleCI’s convenience image](https://hub.docker.com/r/cimg/postgres) as well:

```diff
- postgres:14
+ cimg/postgres:14

```

Alternatively, you can also try [Bitnami’s Postgres images](https://hub.docker.com/r/bitnami/postgresql):

```diff
- postgres:14
+ bitnami/postgresql:14

```

**References:**

- [Postgres:12 container is not starting anymore · Issue #1103 · docker-library/postgres · GitHub](https://github.com/docker-library/postgres/issues/1103#issuecomment-1601343849)
- [Docker image for Postgres 14 based on BookWarm is broken somehow · Issue #1100 · docker-library/postgres · GitHub](https://github.com/docker-library/postgres/issues/1100#issuecomment-1599660628)

---

<div class="post-metadata">

**Author:** ![kelvintaywl](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/kelvintaywl/32/28141_2.png) [@kelvintaywl](https://discuss.circleci.com/u/kelvintaywl)\
**Post date:** [June 26, 2023, 2:43am UTC](https://discuss.circleci.com/t/postgres-container-failing-with-initdb-error-program-postgres-is-needed-by-initdb-but-was-not-found/48470/2 "2023-06-26T02:43:34Z")

</div>

For folks who are interested in confirming the OS version:

```plaintext
$ docker run --rm postgres:13-bullseye cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 11 (bullseye)"
NAME="Debian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

```

```plaintext
$ docker run --rm postgres:13 cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

```
