【问题标题】:Docker centos7 systemctl deos not work : Failed to connect D-busDocker centos7 systemctl deos not work : 无法连接 D-bus
【发布时间】:2017-11-03 06:58:22
【问题描述】:

我正在尝试在 docker 上运行 elasticsearch。

我的功能如下所示

  • 主机系统:OSX 10.12.5
  • 码头工人:17.05.0-ce
  • docker 操作镜像: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 <juneyoung@hanmail.net>

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

【问题讨论】:

  • 为什么在容器内需要systemd?这不是常规方法

标签: elasticsearch docker dbus systemctl


【解决方案1】:

首先,感谢@Robert。 我不这么认为。

我所要做的就是编辑我的CMD 命令。

将其更改为 CMD["elasticsearch"]

但是,必须从浏览器访问一些琐事。 参考this elasticsearch forum post

【讨论】:

  • 我认为这不是一个答案,但至少可以绕道而行。由于没有更多答案,我关闭了这个问题。
【解决方案2】:

如果您要替换普通的 systemctl 命令,您可以按照启用 systemd 的操作系统的命令进行操作。这就是我在 centos docker 容器中安装 elasticsearch 的方式。

详情请见"docker-systemctl-replacement"

【讨论】:

  • 感谢您的回答和精美的实施。我还没有使用它,但看起来不错。我喜欢你解释原因的方式。谢谢!
猜你喜欢
  • 2020-09-07
  • 2017-03-24
  • 1970-01-01
  • 2019-10-10
  • 2018-12-09
  • 2014-10-27
  • 1970-01-01
  • 2019-07-24
  • 2018-02-08
相关资源
最近更新 更多