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.

0

There are 0 answers