i have many IP's on my interface:
inet 10.100.131.115/24 brd 10.100.131.255 scope global br0 valid_lft forever preferred_lft forever inet 10.100.131.120/24 brd 10.100.131.255 scope global secondary br0 valid_lft forever preferred_lft forever inet 10.100.131.121/24 brd 10.100.131.255 scope global secondary br0 valid_lft forever preferred_lft forever inet 10.100.131.122/24 brd 10.100.131.255 scope global secondary br0 valid_lft forever preferred_lft forever
docker-compose.yml:
version: '2' services: app: image: app network_mode: "bridge" volumes: - /root/docker/app/project/:/root/:ro ports: - "7999:7999" network_mode: "bridge"
if i up single container all good:
docker-compose ps Name Command State Ports
docker_app_1 /bin/sh -c uwsgi --ini wsg ... Up 0.0.0.0:7999->7999/tcp
but when i trying scale my app i got error (_ofc, because 7999 is alredy used by docker_app_1_):
docker-compose scale app=2
WARNING: The "app" service specifies a port on the host.
If multiple containers for this service are created on a single host, the port will clash.
Creating and starting docker_app_2 ... error
ERROR: for docker_app_2 Cannot start service app: b'driver failed programming external connectivity on endpoint docker_app_2 (xxxxxxxxxxxxxxxxx...):
Bind for 0.0.0.0:7999 failed: port is already allocated'
Can i tell docker-compose to use all IP's from interface which using IP alising?
i need 1 IP from interface:7999 -> docker container:7999
You can map specific IP's to a container rather than the default of 0.0.0.0. This is not scaling a single service though.
services:
whatever:
ports:
- '10.100.131.121:7999:7999/tcp'
another:
ports:
- '10.100.131.122:7999:7999/tcp'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.