"The page isn’t redirecting properly" when runn

Nope.

You’ve been giving your Docker container your Cloudflare credentials, but doing nothing with them. To enable the DNS challenge, you need to use the tls directive / dns subdirective:

tls (Caddyfile directive) — Caddy Documentation

That means the Docker container has been maintaining certs using HTTP or TLS-ALPN challenges.

Which, in turn, means that you’ve got some other issue going on when you run it manually. Lets walk back to here:

What, specifically, is telling you that Caddy failed to get certs because of a lack of Cloudflare credentials? Was it some output from the Caddy command that indicated this?

I suspect a closer look at the output might give a better idea of what actually failed.

2 Likes