4

I am trying to setup a docker image with Centos7 and PostgreSQL 9.6.

I use the centos:centos7 image as base, and I follow the steps from this page: https://wiki.postgresql.org/wiki/YUM_Installation

The step to initialize the DB

sh-4.2# /usr/pgsql-9.6/bin/postgresql96-setup initdb
Failed to get D-Bus connection: Operation not permitted
failed to find PGDATA setting in postgresql-9.6.service

I tried to follow these steps to enable systemd for the CentOS image, https://hub.docker.com/_/centos/ But it does not help.

I also tried to comment out the stmts in the postgresql96-setup script

#PGDATA=`systemctl show -p Environment "${SERVICE_NAME}.service" |
#                sed 's/^Environment=//' | tr ' ' '\n' |
#                sed -n 's/^PGDATA=//p' | tail -n 1`
#if [ x"$PGDATA" = x ]; then
#    echo "failed to find PGDATA setting in ${SERVICE_NAME}.service"
#    exit 1
#fi

Now the initdb works. But starting the service gives me the same error message

sh-4.2# systemctl enable postgresql-9.6.service
Created symlink from /etc/systemd/system/multi-user.target.wants/postgresql-9.6.service to /usr/lib/systemd/system/postgresql-9.6.service.
sh-4.2#  systemctl start postgresql-9.6.service
Failed to get D-Bus connection: Operation not permitted

Did I miss anything? Anyone can help me out of this?

3
  • Can't you use the official postgres image hub.docker.com/_/postgres Commented Nov 15, 2016 at 1:40
  • @Rao I've got the same problem. The one you link to is not Centos7. The CentOS 7 version doesn't have a "latest". The one they link to is 9.5, not 9.6, and isn't set up as root for futher installs: hub.docker.com/r/centos/postgresql-95-centos7 Commented Aug 16, 2017 at 19:24
  • This seems likely to be a route to a solution for the Failed to get D-Bus connection: Operation not permitted: serverfault.com/questions/824975/… Commented Aug 16, 2017 at 19:40

2 Answers 2

1

The "D-Bus connection: Operation not permitted" is a hint that Postgres wants to talk to the SystemD daemon. I am running Postgres in a centos-7 docker container by using the https://github.com/gdraheim/docker-systemctl-replacement to avoid that situation.

Sign up to request clarification or add additional context in comments.

Comments

0

The underlying problem is explained and can be resolved with this answer:

Failed to get D-Bus connection: Operation not permitted - Server Fault

You make your own new image (centos7-systemd) but it isn't as hard as it looks. But be careful to do exactly what it says, running your new image via:

docker run --privileged -ti -e container=docker -v /sys/fs/cgroup:/sys/fs/cgroup centos7-systemd /usr/sbin/init

and then connect to it via e.g.

$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 6667f8acbe5c centos7-systemd "/usr/sbin/init" 33 minutes ago Up 13 minutes eager_brattain $ docker exec -it eager_brattain bash

Then run those postgres instructions at https://wiki.postgresql.org/wiki/YUM_Installation and they will work fine.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.