5

I am going to deploy my app to production on VPS server, using Docker. My goal is stable version from latest tag at example.com, and dev version from dev tag at dev.example.com.

Because this is an PHP application, container has own nginx+php set. I don't know how - if it's even possible (without Swoole in PHP etc.) to avoid this.

Problem is in resources - I see that each app container has own nginx instance, and server (VPS) must have global nginx, working as reverse proxy for containers.

Is there are any better way to archieve my goals? Thanks!

1
  • 1
    I don't know much about docker, so I can't provide an answer that is helpful. However I know you can build whole servers just serving PHP and use nginx as a proxy, so it should certainly be possible to do the same with docker. Your static files need to be served somehow, not sure if it would be better to have nginx for that in the docker container or make sure they are on external cdn
    – jdog
    Nov 5, 2018 at 23:49

2 Answers 2

1

Problem is in resources - I see that each app container has own nginx instance, and server (VPS) must have global nginx, working as reverse proxy for containers.

Generally speaking yes, this is how this sort of thing goes. It's more of an issue for PHP than other languages because PHP doesn't really have a standalone application server, but instead is commonly deployed using php-fpm with nginx. Since php-fpm supports communication via TCP sockets, theoretically you could run only fpm in the containers and have nginx on the host talk to fpm across the Docker networking layer, but I haven't researched this option enough to be convinced it would work.

Docker makes the most sense when used within the context of an orchestration layer like Kubernetes. Rather than running several Docker containers manually or semi-manually on a particular host, you would schedule them with kubernetes and it would distribute them across its cluster of nodes - the specific machine that runs the container becomes irrelevant. The kubernetes service then provides you with an IP via kube-proxy that load-balances across the pods of that service.

0

you can run one container serving Nginx for others, a container is no different from a server/VM if there is not a specific reason for each container having Nginx. you should clarify why you have one global Nginx and other nodes having Nginx, assume you do not have containers. You say the problem is resources, I am not sure your problem is the way Nginx work or with your design.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.