Docker Community Forums

Share and learn in the Docker community.

Two stacks on a single node - second stack can't bind to unique ports?


(Pukkasoftware) #1

I have one AWS EC2 instance and two stacks (one demo, one beta). The stack definitions are nearly identical. Both use an nginx reverse proxy with config like:

demo:

nginx-api:
  autoredeploy: true
  image: '.../nginx:api-latest'
  links:
    - app
  ports:
    - '9200:80'
    - '9201:443'
  restart: always
nginx-app:
  autoredeploy: true
  image: '.../nginx:app-latest'
  links:
    - app
  ports:
    - '80:80'
    - '443:443'
    - '8088:8088'
  restart: always

beta:

nginx-api:
  autoredeploy: true
  image: '.../nginx:api-latest'
  links:
    - app
  ports:
    - '7200:80'
    - '7201:443'
  restart: always
nginx-app:
  autoredeploy: true
  image: '.../nginx:app-latest'
  links:
    - app
  ports:
    - '7100:80'
    - '7101:443'
    - '7188:8088'
  restart: always

These are websites to answer requests from the Internet and proxy to the backend app server(s). But for some reason the beta site won’t successfully bind to ports 7100/7200. Last night, the services were starting but I couldn’t connect. Now today, they won’t even start saying that the ports are already in use:

[7/29/2016, 11:54:53 AM]ERROR: nginx-api-1: driver failed programming external connectivity on endpoint nginx-api-1.msr-beta.9942959d (a09a9b2a574a6369d1096c69e0a9f68aad5eabada3450eed877a325602b3ddb0): Bind for 0.0.0.0:7201 failed: port is already allocated
[7/29/2016, 11:54:54 AM]ERROR: nginx-app-1: driver failed programming external connectivity on endpoint nginx-app-1.msr-beta.e5c2a3ce (c5613c502f229a6bbecdb06b01c7d46b8f06a9c08088ba766860b6723b73b864): Bind for 0.0.0.0:7101 failed: port is already allocated
[7/29/2016, 11:54:54 AM]ERROR: Stack Start action on 'msr-beta' has failed

This seems like Networking 101: four instances of Nginx running in four containers on a single EC2 node, they are all using different ports. I’ve even shut down the demo instance (relying on 80, 443, 9200 and 9201) and I still get the same error above.

My Nginx config is pretty simple, they all bind to 80/443 in the container and my definition above should be exposing them on different ports.

Is my config wrong? Is this a bug?