我试图使用systemctl命令构建一个CentOS映像。但是每次when我都会构建它。我得到了这个错误:
Step 6/10 : RUN systemctl enable syslog-ng && systemctl start syslog-ng
---> Running in 9a8c5a2cdbae
Failed to get D-Bus connection: Operation not permitted
The command '/bin/sh -c systemctl enable syslog-ng && systemctl start syslog-ng' returned a non-zero code: 1
我的Dockerfile:
FROM centos:7
ENV container docker
RUN yum -y update
RUN yum -y install epel-release && \
yum -y install vim && \
yum -y install wget && \
yum -y install rsync && \
yum -y groupinstall "Development tools"
# Install syslog-ng 3.14
RUN cd /etc/yum.repos.d/ && \
wget https://copr.fedorainfracloud.org/coprs/czanik/syslog-ng314/repo/epel-7/czanik-syslog-ng314-epel-7.repo && \
yum -y install syslog-ng
RUN systemctl enable syslog-ng && systemctl start syslog-ng
RUN yum -y remove rsyslog
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" ]
CMD ["/usr/sbin/init"]
有人知道我做错了什么吗?
谢谢,
发布于 2018-10-10 04:22:08
删除所有systemctl
命令,只需运行syslog
作为CMD来启动它。
CMD ["syslog-ng"]
https://unix.stackexchange.com/questions/474435
复制相似问题