Docker错误:尚未使用SystemD作为Init System(PID 1)启动系统。可以运行。无法连接到巴士:主机降低

发布于 2025-01-21 13:56:56 字数 4718 浏览 5 评论 0原文

我试图用ubi8(rhel8)作为基本图像来编写一个dockerfile来部署Postgresql12和Bucardo。到目前为止,我的dockerfile在下面: -

FROM redhat/ubi8
RUN yum update -y

RUN yum install -y wget zip unzip \
    && yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm \
    && yum update -y \
    && yum install -y postgresql12 postgresql12-server postgresql12-contrib postgresql12-plperl
# RUN  /usr/pgsql-12/bin/postgresql-12-setup initdb
RUN systemctl enable postgresql-12
# RUN systemctl start postgresql-12
RUN yum install -y https://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/p/perl-DBIx-Safe-1.2.5-37.el8.noarch.rpm \
    && yum install -y https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/perl-DBD-Pg-3.7.4-4.module_el8.3.0+426+0b4e9c0a.x86_64.rpm \
    && yum install -y https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/perl-CGI-4.38-2.el8.noarch.rpm \
    && yum install -y https://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/p/perl-boolean-0.46-11.el8.noarch.rpm \
    && yum install -y http://repo.okay.com.mx/centos/8/x86_64/release/perl-open-1.11-416.el8.noarch.rpm \
    && yum install -y perl-ExtUtils-MakeMaker \ 
    && yum install -y perl-Test-Simple perl-Pod-Parser perl-Sys-Syslog \
    && yum install -y make

RUN wget https://bucardo.org/downloads/Bucardo-5.6.0.tar.gz \
    && tar vxfz Bucardo-5.6.0.tar.gz
WORKDIR /Bucardo-5.6.0
RUN perl Makefile.PL \
    && make \
    && make install 
WORKDIR /
RUN rm -rf Bucardo-5.6.0
RUN export PATH=$PATH:/usr/local/bin

RUN set pg_hba local to trust

ADD /startup.sh /startup.sh
RUN chmod +x /startup.sh

ENTRYPOINT ["/bin/bash", "-c", "/startup.sh"]

startup.sh

#!/bin/bash

/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl start postgresql-12
echo "Starting Bucardo..."
su - postgres -c "bucardo install --batch"
su - postgres -c "bucardo start"
su - postgres -c "bucardo show all"
su - postgres -c "bucardo status"

echo "..........Bucardo Status........."
while true; do
    su - postgres -c "bucardo status"
    sleep 5s
done

成功构建图像后,我执行了此docker run -Itd-privileged tech99/ubi8-bucardo/usr/usr/sbin/init < /code>命令运行容器。

docker logs

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
failed to find PGDATA setting in postgresql-12.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

Starting Bucardo...
Current connection settings:
1. Host:           <none>
2. Port:           5432
3. User:           bucardo
4. Database:       bucardo
5. PID directory:  /var/run/bucardo
-->Sorry, unable to connect to the database

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"?
DBI connect('dbname=bucardo','bucardo',...) failed: 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"? at /usr/local/bin/bucardo line 310.
DBI connect('dbname=bucardo','bucardo',...) failed: 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"? at /usr/local/bin/bucardo line 310.
DBI connect('dbname=bucardo','bucardo',...) failed: 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"? at /usr/local/bin/bucardo line 310.
...................
...................

docker top

docker top 1c3c13e2426ebbb619fa4638d8fd6ce02ca564bc9f9aecd27ee21b06a40a4bdd
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                51391               51370               0                   20:41               pts/0               00:00:00            /bin/bash /startup.sh
root                51864               51391               0                   20:42               pts/0               00:00:00            /usr/bin/coreutils --coreutils-prog-shebang

我的问题是为什么不使用SystemD启动容器?我发现启用了基本图像。这个问题有什么工作吗? tia。

I was trying to write a Dockerfile to deploy PostgreSQL12 and Bucardo using Ubi8(RHEL8) as base images. My Dockerfile so far is below:-

FROM redhat/ubi8
RUN yum update -y

RUN yum install -y wget zip unzip \
    && yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm \
    && yum update -y \
    && yum install -y postgresql12 postgresql12-server postgresql12-contrib postgresql12-plperl
# RUN  /usr/pgsql-12/bin/postgresql-12-setup initdb
RUN systemctl enable postgresql-12
# RUN systemctl start postgresql-12
RUN yum install -y https://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/p/perl-DBIx-Safe-1.2.5-37.el8.noarch.rpm \
    && yum install -y https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/perl-DBD-Pg-3.7.4-4.module_el8.3.0+426+0b4e9c0a.x86_64.rpm \
    && yum install -y https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/perl-CGI-4.38-2.el8.noarch.rpm \
    && yum install -y https://download-ib01.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/p/perl-boolean-0.46-11.el8.noarch.rpm \
    && yum install -y http://repo.okay.com.mx/centos/8/x86_64/release/perl-open-1.11-416.el8.noarch.rpm \
    && yum install -y perl-ExtUtils-MakeMaker \ 
    && yum install -y perl-Test-Simple perl-Pod-Parser perl-Sys-Syslog \
    && yum install -y make

RUN wget https://bucardo.org/downloads/Bucardo-5.6.0.tar.gz \
    && tar vxfz Bucardo-5.6.0.tar.gz
WORKDIR /Bucardo-5.6.0
RUN perl Makefile.PL \
    && make \
    && make install 
WORKDIR /
RUN rm -rf Bucardo-5.6.0
RUN export PATH=$PATH:/usr/local/bin

RUN set pg_hba local to trust

ADD /startup.sh /startup.sh
RUN chmod +x /startup.sh

ENTRYPOINT ["/bin/bash", "-c", "/startup.sh"]

startup.sh

#!/bin/bash

/usr/pgsql-12/bin/postgresql-12-setup initdb
systemctl start postgresql-12
echo "Starting Bucardo..."
su - postgres -c "bucardo install --batch"
su - postgres -c "bucardo start"
su - postgres -c "bucardo show all"
su - postgres -c "bucardo status"

echo "..........Bucardo Status........."
while true; do
    su - postgres -c "bucardo status"
    sleep 5s
done

After successfully built the images, I have executed this docker run -itd --privileged tech99/ubi8-bucardo /usr/sbin/init command to run the container.

docker logs

System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
failed to find PGDATA setting in postgresql-12.service
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down

Starting Bucardo...
Current connection settings:
1. Host:           <none>
2. Port:           5432
3. User:           bucardo
4. Database:       bucardo
5. PID directory:  /var/run/bucardo
-->Sorry, unable to connect to the database

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"?
DBI connect('dbname=bucardo','bucardo',...) failed: 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"? at /usr/local/bin/bucardo line 310.
DBI connect('dbname=bucardo','bucardo',...) failed: 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"? at /usr/local/bin/bucardo line 310.
DBI connect('dbname=bucardo','bucardo',...) failed: 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"? at /usr/local/bin/bucardo line 310.
...................
...................

docker top

docker top 1c3c13e2426ebbb619fa4638d8fd6ce02ca564bc9f9aecd27ee21b06a40a4bdd
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                51391               51370               0                   20:41               pts/0               00:00:00            /bin/bash /startup.sh
root                51864               51391               0                   20:42               pts/0               00:00:00            /usr/bin/coreutils --coreutils-prog-shebang

My question is why container not booted with systemd? I found the base images is systemd enabled. Is there any work around for this issue? TIA.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文