Docker Community Forums

Share and learn in the Docker community.

Nginx same container with api

Hi, I have a small question.

I’m build a microservice api. does it make sense to have nginx inside the docker container to expose the api endpoint:port?

or in separated, one docker container with the api and another for the nginx?


PS: would any of those also be valid if there were more than one api (microservice), would they also each container container an nginx and an api?

The scenario is ambigous.

Is nginx ment to be used as reverse proxy or is your api writte in a language that is mento to be run with a nginx module?

Technically no. The language (Go), can create its own server. I was just thing it there was any advantage to add an nginx server inside.

uhm, what about the first part of my question?

Nginx should be in a separate container. Perhaps you’re running on K8s or using Netflix OSS or even a service mesh (such as LinkerD)… all of these options allow for a service registry. Your service, written in GO should just perform the business function that you have defined. The ingress and traffic should be managed by some other means. IMHO

1 Like