2016-11-14 227 views
2

我試圖建立與Centos7和PostgreSQL 9.6碼頭工人的形象。PostgreSQL的9.6 initdb的CentOS中7搬運工容器失敗

我使用CentOS的:centos7圖像爲基礎,因此我遵循此頁面的步驟:https://wiki.postgresql.org/wiki/YUM_Installation

初始化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 

的一步,我試圖按照以下步驟啓用systemd對於CentOS映像, https://hub.docker.com/_/centos/ 但它沒有幫助。

我也試過在postgresql96-setup腳本

#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 

現在initdb的作品註釋掉中的支柱。但開始服務給我同樣的錯誤信息

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 

我錯過了什麼嗎?任何人都可以幫我解決這個問題嗎?

+0

你不能使用官方postgres圖片https://hub.docker.com/_/postgres/ – Rao

+0

@Rao我有同樣的問題。你鏈接到的不是Centos7。 CentOS 7版本沒有「最新」版本。他們鏈接到的是9.5,而不是9.6,並且未安裝爲超級安裝的根目錄:https://hub.docker.com/r/centos/postgresql-95-centos7/ – nealmcb

+0

這似乎很可能是路由到'無法獲得D-Bus連接:不允許操作'的解決方案:https://serverfault.com/questions/824975/failed-to-get-d-bus-connection-operation-not- permit – nealmcb

回答

0

潛在的問題進行了說明,並可以用這個答案來解決:

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

你讓你自己的新形象(centos7-systemd),但它並不難,因爲它看起來。但要小心,這樣做正是它說,通過運行你的新形象:

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

,然後連接到它通過如

$ 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

然後在https://wiki.postgresql.org/wiki/YUM_Installation運行的Postgres的指示,他們會很好地工作。