【发布时间】:2021-07-04 00:48:10
【问题描述】:
在一个 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"]
启动后,在容器中安装postgresql客户端
docker exec -it centos8 /bin/bash
dnf module enable postgresql:12
dnf install postgresql-server
postgresql-setup --initdb
出错了
[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
查看状态
[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
当运行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"?
为什么不能使用systemctl服务?如何在上面安装 Postgres 客户端?
【问题讨论】:
-
这个设置听起来像是在尝试手动配置虚拟机,但在 Docker 容器中的交互式 shell 中。这不是 Docker 的典型用法,尤其是因为一旦容器退出,您安装的任何内容都会丢失。这也不是一个真正的编程问题,而更像是一个 Linux 工具问题。 help center 描述了 Stack Overflow 上允许的主题。
标签: postgresql docker centos8