21

How to expose port ranges (like "3000-4000:3000-4000") in docker-compose.yml file

ports: - "3000-4000:3000-4000"

it not working. Please help me to resolve it

  • Possible duplicate of [Docker expose all ports or range of ports from 7000 to 8000](https://stackoverflow.com/questions/28717464/docker-expose-all-ports-or-range-of-ports-from-7000-to-8000) – Rumid Aug 08 '17 at 06:32
  • How is it "not working". Please provide the error you are getting. – Ayushya Aug 09 '17 at 03:18
  • in docker-compose syntax is different than command line, user is trying to find that, It is not duplicate because that threat is about command line – nerkn Mar 10 '21 at 05:09

1 Answers1

37

There is possibly mistake in the syntax you are using. The ports are defined in the next line and after leaving some space. It should work and as specified in the reference. See example below:

ports:
 - "3000"
 - "3000-3005"
 - "8000:8000"
 - "9090-9091:8080-8081"
 - "49100:22"
 - "127.0.0.1:8001:8001"
 - "127.0.0.1:5000-5010:5000-5010"
 - "6060:6060/udp"
Ayushya
  • 7,869
  • 3
  • 38
  • 57