Reputation: 2573
I am totally new in the cloud stuff, I wanted to deploy my application which using node
,MongoDB
and redis
. all these parts become a docker container and working well together.
now I want to set up nginx
. I wonder what is the best practice for deploying load balancers? should I run nginx
as docker container? or just install it in system level?
Upvotes: 3
Views: 1864
Reputation: 176
I think it depends on how many services you want to serve with your nginx instance. For example, since you can have only one nginx instance bound to the 80 and 443 ports, if you want to share the same SAP between different domains I would go for nginx running on the host (or in a dedicated stack but it looks complex). If you use the SAP for a single domain then it makes perfect sense to have it inside the stack.
Upvotes: 4
Reputation: 1720
It's a really good idea to embed an nginx in your docker network. As a docker container, in a docker network, it could connect to other by their service/container name, while you will define port forwarding rule only on the nginx service.
For example :
docker network create --driver overlay --attachable demo
docker run -d -p 80:80 --network demo --name nginx nginx
docker run -it --network demo --name alpine alpine
Your shell should be in the alpine container. Do a "ping nginx". You should be able to ping it. The opposite is possible too.
So now, you have at localhost:80 (from your host machine) a nginx deployed, which can call other containers with their container/service name. Really useful to have an access point to your web-apis deployed in your docker network.
Upvotes: 1
Reputation: 12100
If you are running other components of the stack on containers , then it makes sense to run nginx as container as well. But it depends on your environment , what tools are available. You can scale nginx on kubernetes easily , as well as on docker swram or any other tool of your choice.
Ideally you need to run each compenent in a separate container so that you can manage and scale and troubleshoot them independently.
Upvotes: 1