docker nginx connection refused while connecting to upstream

You have to define upstream directly. Currently your nginx can not proxy to your web application.

http://nginx.org/en/docs/http/ngx_http_upstream_module.html

upstream backend {
    server backend1.example.com       weight=5;
    server backend2.example.com:8080;
    server unix:/tmp/backend3;

    server backup1.example.com:8080   backup;
    server backup2.example.com:8080   backup;
}

server {
    location / {
        proxy_pass http://backend;
    }
}

My situation was running 3 containers, a nginx container and two containerized services. I was using the Nginx container as a reverse proxy for my go services.

Issue is the nginx container was looking for microservice ports in its own container environment. I didn't realize that at the time and I didn't use the docker-compose.yml then. When using docker-compose.yml file you specify a 'depends-on:...' and that's that

So when running the containers you should use --net=host. Info on that: What does --net=host option in Docker command really do?

This worked for me, I hope it saves someone the pain :):

docker run --net=host nginx:someTag

docker run --net=host service1:someTag