If I already have a LEMP stack and I want to create a 2nd (3rd, 4th, etc.) it seems very (resource) wasteful to spin up additional php and mysql containers. How can I point additional Nginx containers at my existing backend containers?
I found this but it’s a couple years old. Is this still the best practice?
It mentions
You might want to make sure that your containers are on the same network using the
networks
directive. Then they will be able to reach each other via theircontainer_name
.
but my knowledge of Docker is insufficient to know how to use that. Likewise
docker-compose -p SOME_PROJECT -f shared-services.yaml up -d
is confusing for me. Is “SOME_PROJECT” something that I can just randomly specify? Or is it a parameter that exists in conjunction with some containers I’ve already spun up? Also, I’m not sure what shared-services.yml should look like.
If someone could post a shared-services.yml along with app1 and app2 docker-compose files that I could copy and modify, it would be greatly appreciated.
Yep, deploying n docker-compose stack for n environments is still best practice. Though, it is exactly the opposite of what you aim for.
Yes. -p or --project-name is used by docker-compose to distinguish different docker-compose deployments.If you run aboves command with -p A, then again with -p B, you will end up with two distinct deployed docker-compose stacks.