Connect Nginx Docker container to 16 workers

Viewed 365

I have an Nginx Docker container, and 16 load balanced web servers each exposing a port on the host machine, 8081-8096:

docker run -d \
    --restart always \
    --name "web.${name}" \
    -v /srv/web/web-bundle:/bundle \
    -p "${port}":80 \
    kadirahq/meteord:base

My Nginx container was previously linking to the only web image, before I tried to scale:

docker run -d \
    --name nginx \
    --link web.1:web.1 \
    -v /srv/nginx:/etc/nginx \
    -v /srv/nginx/html:/usr/share/nginx/html \
    -p 80:80 \
    -p 443:443 \
    nginx

Nginx upstream config:

upstream web {
        ip_hash;
        server 127.0.0.1:8081;
        server 127.0.0.1:8082;
        server 127.0.0.1:8083;
        # ... you get the point
}

I need this Nginx image to be able to hit 127.0.0.1:8081-8096, however it doesn't appear to permit this. I don't want to make 16 --links! That seems off.

What is the proper way to do this?

1 Answers
Related