我是Docker的新手。我试过在opensuse13.2 docker image上安装snmpd。安装完成。 Docker构建执行得很好。但是当我尝试重新启动或检查snmpd服务的状态时,我收到了以下错误
" snmpd既不是服务也不是目标!?"
我的Dockerfile:
FROM opensuse:13.2
RUN zypper update \
&& zypper ar -Gf -n packman http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_13.2/ packman \
&& zypper ar -G http://download.opensuse.org/repositories/devel:languages:perl/openSUSE_13.2/devel:languages:perl.repo \
&& zypper --non-interactive install net-snmp
COPY entrypoint.sh /docker/
RUN chmod 755 /docker/entrypoint.sh
ENTRYPOINT ["/docker/entrypoint.sh"]
entrypoint.sh:
printf 'rocommunity public 127.0.0.1 \nagentaddress udp:127.0.0.1:161' >> /etc/snmp/snmpd.conf
service snmpd restart
service snmpd status
echo "restarted snmp"
Docker构建输出:
[root@atvts2508 docker_test]# docker build -t snmp .
Sending build context to Docker daemon 4.608kB
Step 1/5 : FROM opensuse:13.2
---> a0ae1667209e
Step 2/5 : RUN zypper update && zypper ar -Gf -n packman http://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_13.2/ packman && zypper ar -G http://download.opensuse.org/repositories/devel:languages:perl/openSUSE_13.2/devel:languages:perl.repo && zypper --non-interactive install net-snmp
---> Using cache
---> 6d2d62d8e3c7
Step 3/5 : COPY entrypoint.sh /docker/
---> Using cache
---> db5f208d9464
Step 4/5 : RUN chmod 755 /docker/entrypoint.sh
---> Using cache
---> 163ab499d864
Step 5/5 : ENTRYPOINT /docker/entrypoint.sh
---> Using cache
---> 495dd68f290f
Successfully built 495dd68f290f
**Docker run output:**
[root@atvts2508 docker_test]# docker run -it snmp bash
snmpd is neither service nor target!?
snmpd is neither service nor target!?
restarted snmp
我做错了吗? 有人可以帮帮我吗?提前谢谢。