I haven’t used Caddy yet, so can you explain why you think it should work? What do the configuration parameters do? All I see referring to localhost localhost is different in each container. And I see no reference to the API at all. So what is your expectation and based on what?
On user-defined networks like those created by Docker Compose DNS resolution works for containers and you can use the compose service name or container name as domain name.
Hello, I know this answer is late, but I believe in order to keep your ports blocked externally you should express them differently in your Docker Compose file – instead of opening the port to external network traffic like 8000:8000 you can only allow access to this port on the private docker network with simply 8000.
I’m running Caddy + Nuxt + API (Rails) and I don’t allow Rails external network access, since the only container needing to access Rails is my Caddy proxy container. However, from your diagram you may not be running Caddy as a docker container like me? In my setup the only ports I leave open externally are on the Caddy container per their documentation.