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
[root@centos8 /]# 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
[root@centos8 /]# 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
When run psql
[root@centos8 /]# psql
psql: error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Why can't use systemctl service? How to install a Postgres client on it?