1

I trying to build a CentOS image with systemctl command. But each time when I build it. I obtain this error :

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

My 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"]

Someone know what I do wrong ?

Thanks,

8
  • Is SELInux enabled, anything relevant in audit log (/var/log/audit/audit.log)?
    – sebasth
    Oct 10 '18 at 9:00
  • @sebasth audit log of the Docker Host ?
    – DevHugo
    Oct 10 '18 at 9:02
  • SELInux is not install.
    – DevHugo
    Oct 10 '18 at 9:30
  • The Dockerfile is read sequentially, so can you try putting your systemctl commands at the end of the file, after the RUN/VOLUME/CMD set of commands?
    – Haxiel
    Oct 10 '18 at 10:43
  • @Haxiel Same error
    – DevHugo
    Oct 10 '18 at 11:55
0

Remove all systemctl commands and just run syslog as CMD to start it.

CMD ["syslog-ng"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.