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

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"

Leave a Comment