Please excuse me for not using the template, considering the simplicity of the question, I thought it would be unnecessary.
I have multiple docker containers running (specified in separate docker-compose files), which all serve webpages in some form (apart from other various functionality).
My goal is simple: use Caddy as a reverse proxy to serve the webpages at various subdomains.
My question is: I would like to keep everything containerized, so ideally, I would like to run Caddy as a container. However, if I define a Caddy container in one docker-compose file, other Docker containers won’t have access to Caddy, right? This is partially a Docker-related question, is this possible or would it be better to run Caddy non-dockerized on my server?
I am a happy caddy user, and I have an experience with your basic question.
What you trying to do is absolutely possible.
Just run caddy in one docker-compose file, then configure your other docker containers to join caddy’s network.
for example, if your caddy run on caddy_network
then configure your other docker container by using this:
or, you can browse docker documentation for that.
Hope that help.
Thank you for your reply. That does seem the cleanest way to solve the problem.
If I understand correctly, I can specify in docker-compose files which containers should have access to
caddy_network and these containers will still have access to the network of the compose file (so they could interact with their container db etc)?
The other idea I had was having Caddy access everything through the bridge network of Docker (the standard network that every container on the same host is connected to). However it’s a bit less performant and I think advanced things such as load balancing aren’t possible on the bridge network.
Yes, every container that join
caddy_network can interact each others.
Yep - as long as all the containers you want Caddy to proxy to are in the same Docker network, it will work.
You could just write your own docker-compose file which has all the services you want to run.
Here’s a page from the docs that might help get you started:
This topic was automatically closed after 30 days. New replies are no longer allowed.