2017-06-02 108 views
0

我試圖在docker上運行elasticsearch。Docker centos7 systemctl deos無法正常工作:無法連接D-bus

我的功能,如下面

  • 主機系統:OSX 10.12.5
  • 泊塢窗:17.05.0-CE
  • 搬運工人操作圖像:centos:latest

我下面this article,但它堅持systemctl daemon-reload

我發現CentOS official respond關於此D-bus錯誤,但是當我運行docker run命令時,它顯示下面的消息。 [!!!!!!] Failed to mount API filesystems, freezing.

我該如何解決這個問題?

僅供參考,這裏是Dockerfile我打造形象

FROM centos 
MAINTAINER juneyoung <[email protected]> 

ARG u=elastic 
ARG uid=1000 
ARG g=elastic 
ARG gid=1000 
ARG p=elastic 

# add USER 
RUN groupadd -g ${gid} ${g} 
RUN useradd -d /home/${u} -u ${uid} -g ${g} -s /bin/bash ${u} 


# systemctl settings from official Centos github 
# https://github.com/docker-library/docs/tree/master/centos#systemd-integration 
ENV container docker 
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \ 
systemd-tmpfiles-setup.service ] || rm -f $i; done); \ 
rm -f /lib/systemd/system/multi-user.target.wants/*;\ 
rm -f /etc/systemd/system/*.wants/*;\ 
rm -f /lib/systemd/system/local-fs.target.wants/*; \ 
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ 
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ 
rm -f /lib/systemd/system/basic.target.wants/*;\ 
rm -f /lib/systemd/system/anaconda.target.wants/*; 
VOLUME [ "/sys/fs/cgroup" ] 



# yum settings 
RUN yum -y update 
RUN yum -y install java-1.8.0-openjdk.x86_64 
ENV JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.131-3.b12.el7_3.x86_64/jre/ 

# install wget 
RUN yum install -y wget 

# install net-tools : netstat, ifconfig 
RUN yum install -y net-tools 

# Elasticsearch install 
ENV ELASTIC_VERSION=5.4.0 
RUN rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch 
RUN wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-${ELASTIC_VERSION}.rpm 
RUN rpm -ivh elasticsearch-${ELASTIC_VERSION}.rpm 


CMD ["/usr/sbin/init"] 

,我已經用命令

docker run -ti -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name=elastic2 elastic2

+2

爲什麼你需要容器​​內的'systemd'?這不是常規方法 – Robert

+1

@Robert謝謝! –

+0

不客氣! – Robert

回答

1

首先感謝@Robert跑去。 我並沒有這麼想。

我只需要編輯我的CMD命令即可。

改變,要 CMD["elasticsearch"]

然而,有一些瑣事,從瀏覽器進行訪問。 參考this elasticsearch forum post

+0

我認爲這不是一個答案,但至少能夠繞道。由於沒有更多的答案,我關閉了這個問題。 –

1

如果要替換正常的systemctl命令,您可以按照啓用systemd的操作系統的命令進行操作。這就是我在centos docker容器中安裝elasticsearch的方式。

有關詳細信息,請參見"docker-systemctl-replacement"

+0

感謝您的回答和花哨的實施。我沒有使用它,但看起來不錯。我喜歡你解釋原因的方式。謝謝! –