初步猜测原因是:keepalived容器内的keepalived.pid文件在keepalived容器非正常退出时,没有正确删除,造成第二次启动时容器检查到pid文件已经存在,认为该进程已经存在,因为keepalived容器的启动检查机制只允许同一台主机上启动一个进程,所以无法启动,并报错:daemon is already running
注:该问题是keepalived软件本身存在的一个bug,如果需要优化,可以考虑在keepalived容器内增加脚本,在keepalived容器启动前进行一次清理动作,主动清理掉原来的keepalived.pid文件,待验证
已验证:上面猜测的原因是正确的
可以重新构建keepalived镜像,在启动keepalived之前删除一遍keepalived.pid文件即可
新的dockerFile文件
FROM keepalived:1.3.5.0 MAINTAINER wulj COPY keepalived.sh /etc/init.d/ RUN chmod +x /etc/init.d/keepalived.sh ENTRYPOINT ["/etc/init.d/keepalived.sh"]
keepalived.sh文件
#!/bin/bash #decription:start keepalived echo `ps -ef` > /winhong_test.txt rm -rf /var/run/keepalived.pid /usr/sbin/keepalived --dont-fork --log-console --log-detail
keepalived 容器在宿主机重启后无法启动问题:报错:daemon is already running
原文:https://www.cnblogs.com/caogen1991/p/11338020.html