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?
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:
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.
Most helpful comment
I think what would be valuable here is the ability to do:
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.