How to use centos:8 docker image run postgresql client?

  centos8, docker, postgresql

In a centos 8 Dockerfile

FROM centos:8

RUN yum update -y && yum install -y openssh-server sudo && yum clean all
RUN rm -rf /run/nologin

EXPOSE 22
CMD ["/usr/sbin/sshd", "-D"]

After start it, install postgresql client in the container

docker exec -it centos8 /bin/bash

dnf module enable postgresql:12
dnf install postgresql-server
postgresql-setup --initdb

Got an error

[[email protected] /]# postgresql-setup --initdb
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
FATAL: no db datadir (PGDATA) configured for 'postgresql.service' unit

Check status

[[email protected] /]# systemctl status postgresql
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

Why can’t use systemctl service? How to install a Postgres client on it?

Source: Docker Questions

LEAVE A COMMENT