이 Dockerfile에서이 오류가 발생했습니다.
FROM centos:latest
ENV container docker
MAINTAINER The CentOS Project <[email protected]>
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"]
하나를 사용하려고 할 때 docker-compose
또는 docker build
이 오류가 나타납니다
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
나는 모든 곳을 보았지만 해결책은 없습니다. 도커로 할 수 없다면 어떤 컨테이너를 배울 수 있는지 알려주세요.
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
다운로드하여 실행하면 실행 centos:latest
되지 않는 CentOS 8 Docker 컨테이너가 제공 systemd
됩니다. systemd
작동 하려면 더 많은 작업 이 필요 하지만 Docker는 컨테이너 내부에서 단일 프로세스를 실행하도록 설계되었으므로 init 시스템이 실제로 필요하지 않습니다.
상기 찾고 Zabbix에 의해 생산 Zabbix 에이전트 Dockerfile , 그것은 사용하지 않습니다 systemd
.
사용 zabbix/zabbix-agent:centos-5.0-latest
하고 더 잘 작동하는지 확인해 보셨습니까 ?
댓글 후 업데이트 :
다음 권장 사항을 사용한 후 Dockerfile의 모습은 다음과 같습니다.
FROM zabbix/zabbix-agent:centos-5.0-latest
ENV container docker
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
그런 다음 Docker 컨테이너를 배포 할 호스트의 컨텍스트에서 조정 zabbix-speedtest.service
하고 zabbix-speedtest.timer
실행 해야합니다 .
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다