Docker shutting down Caddy at 11PM every day

Hi there,

Im new to this, so please do point out stupid things…

Im hosting a website on a KVM, and am using Caddy as my reverse proxy running in a Docker container. For some reason, every night at 11PM on the dot. the machine shuts down with exit code 0, which according to what I can find, means that there are no foreground processes running.

I have tried re-installing, and using a different config that I know works, but still no luck…

I have asked a friend that is running the same setup, but he has not ever had this problem.

My Caddyfile is (edited to hide IPs):

site1.domain.com {

reverse_proxy 0.0.0.0:5080
}

site2.domain.com {
reverse_proxy 0.0.0.0:8080
}

I’ve posted on the Caddy forums as well, in case its something there, but seeing that Caddy is receiving the shutdown command from Docker, I think its a docker problem…

I assume you mean the container exits, because its foreground process is stopped/finished.

Docker doesn’t interfere with processes inside a container. As you experience the same situation every day at the same time, it is probably more likely that a scheduler (unrelated to docker), like cron, has a job that causes this behavior.

Usually accessing a container by it’s container ip is not the right approach, as container ips are not permanent and can eventually change. The intended approach is to create a user defined docker network, and leverage dns-based service discovery, which allows resolving a container name (in case of compose the service name as well) via dns to the current container ip.

Since your post is in the docker-compose category, it is high likely that you already use a user defined network (all networks defined in a compose file are user defined). So the only thing you would need to change in your caddyfile is to use {service name}:{container port} instead of ip:port.

I doubt it will fix your issue, but it will prevent the reverse proxy rule to point to a non-existing ip.
Still, I assume what you experience is caused by some sort of cronjob.