我正在尝试docker化一个AEM6.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/
发布于 2017-10-24 07:29:30
这里的问题是,您试图在“构建”阶段启动aem服务,使用以下语句:
RUN service aem6 start这是有问题的,原因有很多。首先,您正在构建一个映像。在此阶段启动服务是pointless...when构建过程完成,没有运行任何内容。图像只是文件的集合。在引导容器之前,您没有任何进程,此时您的CMD和ENTRYPOINT会影响正在运行的内容。
另一个问题是,在这个阶段,容器环境中没有运行任何其他东西。本例中的service命令尝试使用dbus应用编程接口与systemd通信,但这两个服务都没有运行。
还有第三个稍微更微妙的问题:您选择的解决方案依赖于标准的CentOS流程管理器systemd,就目前情况而言,您已经正确地进行了配置(通过使用systemctl enable ...启用服务并在CMD语句中启动/sbin/init )。然而,在容器中运行systemd可能会很棘手,尽管这是可能的。在过去,systemd要求容器使用--privileged标志运行;我不确定是否需要这样做。
如果您没有在容器中运行多个进程(dnsmasq和aem),最简单的解决方案是直接启动aem服务,而不是依赖进程管理器。这将把你的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容器共享相同的网络环境)。
https://stackoverflow.com/questions/46887791
复制相似问题