我尝试使用 systemctl 命令构建 CentOS 映像。但每次当我建造它时。我收到此错误:
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"]
有人知道我做错了什么吗?
谢谢,
答案1
删除所有systemctl
命令并syslog
以 CMD 身份运行来启动它。
CMD ["syslog-ng"]