Skip to content

PostgreSQL#

The Lagoon PostgreSQL Docker image. Based on the official PostgreSQL Alpine images.

Supported versions#

  • 11 Dockerfile (Security Support until November 2023) - uselagoon/postgres-11
  • 12 Dockerfile (Security Support until November 2024) - uselagoon/postgres-12
  • 13 Dockerfile (Security Support until November 2025) - uselagoon/postgres-13
  • 14 Dockerfile (Security Support until November 2026) - uselagoon/postgres-14
  • 15 Dockerfile (Security Support until November 2027) - uselagoon/postgres-15

Note:

We stop updating EOL PostgreSQL images usually with the Lagoon release that comes after the officially communicated EOL date: https://www.postgresql.org/support/versioning

Lagoon adaptions#

The default exposed port of postgres containers is port 5432.

To allow Lagoon to select the best way to run the postgres container, use lagoon.type: postgres - this allows DBaaS operator to provision a cloud database if available in the cluster. Use lagoon.type: postgres-single to specifically request postgres in a container. Persistent storage is always provisioned for postgres containers at /var/lib/postgresql/data.

docker-compose.yml snippet#

```yaml title="docker-compose.yml snippet"
    postgres:
      image: uselagoon/postgres-14-drupal:latest
      labels:
        # tells Lagoon this is a postgres database
        lagoon.type: postgres
      ports:
        # exposes the port 5432 with a random local port, find it with `docker-compose port postgres 5432`
        - "5432"
      volumes:
        # mounts a named volume at the default path for postgres
        - db:/var/lib/postgresql/data
```

Tips & Tricks#

If you have SQL statements that need to be run immediately after container startup to initialize the database, you can place those .sql files in the container's docker-entrypoint-initdb.d directory. Any .sql files contained in that directory are run automatically at startup, as part of bringing the PostgreSQL container up.

Note:

Take note that these scripts are only run if the container is started with an empty database.