osixia / docker-keepalived

Keepalived container image 🐳🌴
MIT License
395 stars 143 forks source link

when using our own keepalived config file, and then we modify it, actually it has no effect #22

Open BloodyKnight opened 6 years ago

BloodyKnight commented 6 years ago

when use our own config file, eg: docker run \ --cap-add=NET_ADMIN \ -v /data/safe_town/ha/data/keepalived/conf/keepalived.conf:/container/service/keepalived/assets/keepalived.conf \ --net=host \ --name=keepalived \ --privileged=true \ -d 360/keepalived_cluster:1.4.2 --loglevel debug --copy-service obviously,the config file is /data/safe_town/ha/data/keepalived/conf/keepalived.conf, then we edit it for some reason, but it has no effect. after reviewing your code, I found that in the start.sh: if [ ! -e "/usr/local/etc/keepalived/keepalived.conf" ]; then ln -sf ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf /usr/local/etc/keepalived/keepalived.conf fi so, we check the /usr/local/etc/keepalived/keepalived.conf file and the ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf file, we find that the ${CONTAINER_SERVICE_DIR}/keepalived/assets/keepalived.conf has modified as expected, but the /usr/local/etc/keepalived/keepalived.conf does not, WHY? And then I found https://github.com/moby/moby/issues/13382, itseems that symbol link files are not well supported within docker,so I suggested that U can remove the link symbol file in order to support modifying configuration on the fly(at least restart).

sorry, we found that the problem is the two directory(/container/run/service and /container/service) are not consistent.

linkvt commented 3 years ago

Hi, I also noticed the same issue and think this is because the config files are only copied on the first container start when using --copy-service, see https://github.com/osixia/docker-light-baseimage/blob/434a7084d82ceaeb3a76b1c268916a463851550b/image/tool/run#L378-L381

@BertrandGouny is this intended to only copy the config files at the first start? Otherwise we could move the lines reference here above the if clause checking for the first start (and test again to confirm of course).