SUSE Support

Here When You Need Us

postgresql-server fails to start in sle-bci container

This document (000021398) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 15 Service Pack 5

Situation

The postgres server as part of a customised SUSE Linux Enterprise images based on the sle-bci registry.suse.com/bci/bci-base:15.5 image fails to start with the following error:

FATAL:  could not create lock file "/run/postgresql/.s.PGSQL.5432.lock": No such file or directory

Resolution

There are three options to prevent the problem.
  1. Use the registry.suse.com/suse/postgres:latest image created by SUSE. See https://registry.suse.com/categories/apps/repositories/suse-postgres16 for more information. This image was designed to ease containerised deployment of postgresql-server.
  2. Install systemd along with postgresql-server
  3. Execute the following command to create /run/postgresql with the metadata specified in /usr/lib/tmpfiles.d/postgresql.conf after installing the postgresql-server package :
    install -d /run/postgresql -m 1775 -g postgres -o postgres
    

Cause

Up until including postgresql-server-15-150500.8.19 the RPM had a dependency on the systemd RPM and its dependency tree.
As part of a general attempt to slim down the SUSE Base Container Image (see https://registry.suse.com/categories/bci) sizes, the dependency on systemd was removed in the postgresql-server-16-150500.10.3.2 maintenance update.
This causes the /run/postgresql/ directory to not get created by systemd-tmpfiles-setup.service as part of the installation.
Based on information in /usr/lib/tmpfiles.d/postgresql.conf systemd-tmpfiles-setup.service will create /run/postgresql/ when systemd is installed in the container.

Additional Information

Example of a container creation, which installs the packages, sets up the /run/postgresql directory, initiates PostgreSQL database and starts the PostgreSQL server is shown below.
Note that this is a very simplified example just demonstrating the core basics of the concept. Normally a persistent volume would be used for the data store. Also, once the container is terminated, the volatile /run/ directory is lost. 
docker run -it registry.suse.com/bci/bci-base:15.5 /bin/bash -c \
'zypper -n in sudo postgresql-server; \
install -d /run/postgresql -m 1775 -g postgres -o postgres;\
sudo -u postgres pg_ctl init -D /var/lib/pgsql; \
sudo -u postgres pg_ctl -D /var/lib/pgsql start' 
Another simplified example is building an image with the PostgreSQL server installed and database initialised. In this case /run/postgresql is preserved for the subsequent instantiations of the image.

Content of Dockerfile :
FROM registry.suse.com/bci/bci-base:15.5
RUN zypper -n in postgresql-server sudo
RUN install -d /run/postgresql -m 1775 -g postgres -o postgres
RUN sudo -u postgres pg_ctl init -D /var/lib/pgsql
ENTRYPOINT sudo -u postgres pg_ctl -D /var/lib/pgsql start && sleep infinity


Build a named image from the Dockerfile :
# docker build -t pg_image .
...
Successfully built 92c45077517a
Successfully tagged pg_image:latest
Run a container from the image :
# docker run -it pg_image
waiting for server to start....2024-03-15 11:10:31.413 UTC   [11]LOG:  redirecting log output to logging collector process
2024-03-15 11:10:31.413 UTC   [11]HINT:  Future log output will appear in directory "log".
 done
server started

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000021398
  • Creation Date: 15-Mar-2024
  • Modified Date:15-Mar-2024
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.