docker上的AEM 6.0 – Dbus连接错误

我试图dockerize AEM 6.0安装,这是我的作者的Dockerfile。

from centos:latest COPY aem6.0-author-p4502.jar /AEM/aem/author/aem6.0-author-p4502.jar COPY license.properties /AEM/aem/author/license.properties RUN yum install dnsmasq -y RUN systemctl enable dnsmasq RUN yum install initscripts -y 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/*; WORKDIR /AEM/aem/author RUN yum install wget -y RUN wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.rpm" RUN yum localinstall jdk-8u151-linux-x64.rpm -y RUN java -XX:MaxPermSize=256m -Xmx512M -jar aem6.0-author-p4502.jar -unpack COPY aem6 /etc/init.d/aem6 RUN chkconfig --add aem6 RUN yum -y install initscripts && yum update -y & yum clean all RUN chown -R $USER:$(id -G) /etc/init.d RUN chmod 777 -R /etc/init.d/aem6 RUN systemctl enable aem6.service RUN service aem6 start VOLUME /sys/fs/cgroup CMD /usr/sbin/init 

生成启动服务失败,错误 – failed to get Dbus connection error 。 我一直无法弄清楚如何解决这个问题。

我试过这些 – https://github.com/CentOS/sig-cloud-instance-images/issues/45 – https://hub.docker.com/_/centos/

在这里,问题是你正在尝试在“构build”阶段启动aem服务,并声明如下:

 RUN service aem6 start 

由于多种原因,这是有问题的。 首先,你正在build立一个形象。 在这个阶段启动一个服务是毫无意义的…当构build过程完成时, 什么也没有运行。 图像只是文件的集合。 在启动容器之前,您没有任何进程 ,此时您的CMDENTRYPOINTENTRYPOINT影响正在运行的内容。

另一个问题是,在这个阶段,容器环境中没有别的东西在运行。 在这种情况下, service命令正尝试使用dbus API与systemd进行通信,但是这两个服务都没有运行。

还有一个稍微更微妙的问题:你select的解决scheme依赖于systemd ,标准的CentOS进程pipe理器,而且systemctl enable ...你已经正确地configuration了事情(通过使用systemctl enable ...启用服务和通过在您的CMD语句中启动/sbin/init )。 但是,在一个容器中运行systemd可能会非常棘手,尽pipe这是可能的。 在过去, systemd需要容器运行 – – --privileged标志; 我不确定这是否有必要。

如果你没有在容器中运行多个进程(dnsmasq和aem),最简单的解决scheme是直接启动aem服务,而不是依靠进程pipe理器。 这会减less你的Dockerfile到像这样的:

 FROM centos:latest COPY aem6.0-author-p4502.jar /AEM/aem/author/aem6.0-author-p4502.jar COPY license.properties /AEM/aem/author/license.properties WORKDIR /AEM/aem/author RUN yum install wget -y RUN wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u151-b12/e758a0de34e24606bca991d704f6dcbf/jdk-8u151-linux-x64.rpm" RUN yum localinstall jdk-8u151-linux-x64.rpm -y RUN java -XX:MaxPermSize=256m -Xmx512M -jar aem6.0-author-p4502.jar -unpack CMD some commandline to start aem 

如果你真的需要dnsmasq,你可以在第二个容器中运行它(可能与aem容器共享相同的networking环境)。