Search code examples
amazon-web-servicesdockernginxodoo

link from ngnix installed outside docker to a container


friends, I have a ubuntu server with ngnix installed outside of docker.

I have a docker image that has a web application, with an ip for example: 172.17.0.3 (all within the same server)

How can I do it from my nginx to the ip of the name container? for example: "ip container docker"

That structure cannot change, that's how aws service creates it. * obs: the Ip can change because of that I need as a dynamic variable.

upstream openerp {
server "ip container docker":8069;}

use: $host or hotname, not work


Solution

  • You should publish your docker container port on the docker host and use server 127.0.0.1:your_mapped_docker_container_port.

    Read more details in the docker docs https://docs.docker.com/config/containers/container-networking/#published-ports

    This way docker will take care of everything docker networking related under the hood.