-
-
Notifications
You must be signed in to change notification settings - Fork 770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to run multiple projects #611
Comments
Hello @JoppeDC! You can use the You will also have to configure the network for Docker so that applications can be launched on the necessary ports and make changes in Example by steps:
docker network create -o 'com.docker.network.bridge.host_binding_ipv4=127.0.10.1' app1
docker network create -o 'com.docker.network.bridge.host_binding_ipv4=127.0.10.2' app2
docker network create -o 'com.docker.network.bridge.host_binding_ipv4=127.0.10.3' app3
+ app1.localdomain www.app1.localdomain 127.0.10.1
+ app2.localdomain www.app2.localdomain 127.0.10.2
+ app3.localdomain www.app3.localdomain 127.0.10.3
services:
php:
+ networks: ["app1"]
...
database:
+ networks: ["app1"]
...
networks:
...
+ app1:
+ external: true The created networks must be configured for all project containers. Each project should have its own network. After this configuration, each of the projects will be launched on the same port, but have different host names (addresses). This will allow you to run multiple servers on the same port. Reference: |
Thanks for this very fast reply @7-zete-7 ! This looks very promising. I did not know about Although i'm unable to get this to work (I cant even visit the IP directly without the hosts config, which is not 1 to 1 because i'm using mac), it might be related to the fact i'm using Macos. It seems like this caddy container is a cool and simple way to work on a single project, but quickly introduces a lot of complexities when using multiple projects. Which is why i find it a lil sad that this is the "Official" symfony method. |
We are using Traefik for this purpose - you can have any number of docker-compose projects, on each of them you add a "label" to docker-compose file with a hostname to which it should respond, and then Traefik is the only one listening on 80/443 and transferring traffic to actual HTTP servers (like Caddy). If you use whatever.localhost, then you even don't need to touch hosts file, as everything is by default automatically recognized and sent to proper container. |
For completeness, i'm gonna add how i resolved this, witgout the use of a proxy or networks. So. Caddy NEEDS 80 and 443, when using it out of the box. This is because it automatically requests ssl etc. Now, if you run it with docker auto generated ports, it doesnt work. Its internal config needs to map the port to the “site” (as you would in eg. nginx or apache config). So, what you can do, is provide your own certs (with mkcert, just add em to the repo), and run it on 2 other fixed ports. (Eg. 2015 for http and 20015 for https), you then need to configure these ports in the caddyfile as well for the caddy config, and boom, custom ports per project. Only downside, you still need to define 2 ports in the .env file (i reuse those in docker and caddy config). So need to make sure every project has its own port defined |
Hello!
I just wanted to verify that, with this image using Caddy, its impossible to run multiple projects side by side.
For example, i often work on several projects, and leave all their containers running.
Running a single project with this dockerfile is fine, but with multiple projects the ports collide (and Caddy needs those specific ports, it appears you cant use the docker auto generated ports).
Is this correct? If so, i'm not sure this is a perfect solution. Running multiple projects is often a must, and therefore, maybe we can look for a solution?
The text was updated successfully, but these errors were encountered: