Compose: Scale a container specifying ports

Created on 2 Apr 2015  路  7Comments  路  Source: docker/compose

Currently the docker-compose scale command creates random ports for the new containers.

Is there a way to specify a port for the new containers?

kinquestion

Most helpful comment

I think what would be valuable here is the ability to do:

postgres:
  image: postgres:9.5
  environment:
    - POSTGRES_PASSWORD=postgres
  ports:
    - 5432+:5432

Thus allowing the scale=4 to create 4 instances published on 5432, 5433, 5434, 5435, but all routing to their internal ports. The reasons for this over a separate linked haproxy instance are many.

Naming convention and definitions here is open to improvement obviously.

All 7 comments

I'm wondering the same thing.

in your docker-compose.xml,

postgres:
  image: postgres:9.5
  environment:
    - POSTGRES_PASSWORD=postgres
  ports:
    - 5432:5432

it will bind to 5432, however, note that you can't have more than one instance on the same node for obvious reason.

I think what would be valuable here is the ability to do:

postgres:
  image: postgres:9.5
  environment:
    - POSTGRES_PASSWORD=postgres
  ports:
    - 5432+:5432

Thus allowing the scale=4 to create 4 instances published on 5432, 5433, 5434, 5435, but all routing to their internal ports. The reasons for this over a separate linked haproxy instance are many.

Naming convention and definitions here is open to improvement obviously.

Doesn't port range works? - 5432-5440

@arthurtsang It's a "yml" file, not "xml" ;-)

Duplicate of #722

Will this be implemented?

The below configuration in docker-compose file with a replica of 5 will create five containers with same VNC port and different internal IP or hostname. If we did the same thing on an ec2 machine then how we access those VNC desktops via public IP?

====
chrome_node1:
image: selenium/node-chrome-debug:3.141.59-gold
depends_on:
- hub
environment:
- HUB_PORT_4444_TCP_ADDR=hub
- HUB_PORT_4444_TCP_PORT=4444
networks:
- test
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME -port 5557" /opt/bin/entry_point.sh'
ports:
- "5557:5900"
deploy:

replicas: 5

Adding the same entry multiple times in docker-compose file with different IP will do the trick but I am looking for any other alternative solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bitver picture bitver  路  3Comments

guycalledseven picture guycalledseven  路  3Comments

maltefiala picture maltefiala  路  3Comments

HackerWilson picture HackerWilson  路  3Comments

29e7e280-0d1c-4bba-98fe-f7cd3ca7500a picture 29e7e280-0d1c-4bba-98fe-f7cd3ca7500a  路  3Comments