Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not scale service to multiple container when binding host port in docker-compose.yml

Micro service is running on one container. I have bound that service to Host port 8082 and launched this micro service using docker-compose. Now I want to scale it to 3 container using docker-compose scale command but it giving me following error-

ERROR: for 2 failed to create endpoint composetest_nginx_2 on network composetest_default: Bind for 0.0.0.0:8082 failed: port is already allocated

ERROR: for 3 failed to create endpoint composetest_nginx_3 on network composetest_default: Bind for 0.0.0.0:8082 failed: port is already allocated

What would be the solution for this?

like image 741
suraj chopade Avatar asked Apr 05 '16 12:04

suraj chopade


1 Answers

I solved it by passing a port range, with the correct syntax :P

ports:
      - "9110-9120:3333"
like image 106
Sean Moghadam Avatar answered Sep 20 '22 09:09

Sean Moghadam