I am facing this error with this Dockerfile:
FROM centos:latest
ENV container docker
MAINTAINER The CentOS Project <cloud-ops@centos.org>
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" ]
RUN rpm -U https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
RUN yum -y install zabbix-agent
RUN yum clean all
COPY ./zbx-speedtest.sh /etc/zabbix/bin/zbx-speedtest.sh
RUN chmod +x /etc/zabbix/bin/zbx-speedtest.sh
COPY ./speedtest.conf /etc/zabbix/zabbix_agentd.d/speedtest.conf
COPY ./zabbix-speedtest.service /etc/systemd/system/zabbix-speedtest.service
COPY ./zabbix-speedtest.timer /etc/systemd/system/zabbix-speedtest.timer
RUN systemctl enable zabbix-speedtest.timer
RUN systemctl enable zabbix-agent.service
RUN systemctl start zabbix-agent.service
RUN systemctl start zabbix-speedtest.timer
CMD ["/usr/sbin/init"]
When trying to use either docker-compose
or docker build
I receive this error:
Failed to get D-Bus connection: Operation not permitted
ERROR: Service 'zbx' failed to build: The command '/bin/sh -c systemctl start zabbix-agent.service' returned a non-zero code: 1
I looked everywhere, nothing is up for a solution. If it is impossible to do that with docker, please tell me which container to learn that can do that?
zabbix-speedtest.timer
[Unit]
Description=Run a speedtest every 5 minutes
[Timer]
OnCalendar=*:0/5
# RandomizedDelaySec=30
[Install]
WantedBy=timers.target
zabbix-speedtest.service
[Unit]
Description=Run a speedtest
After=network.target
[Service]
Type=simple
#User=zabbix-agent
#User=root
User=zabbix
ExecStart=/etc/zabbix/bin/zbx-speedtest.sh --run
CPUSchedulingPolicy=fifo
CPUSchedulingPriority=80
[Install]
WantedBy=multi-user.target
systemd
running within them. Maybe try hub.docker.com/r/centos/systemd