Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 751
Murali Manchadikkal Avatar asked Aug 08 '17 06:08

Murali Manchadikkal


People also ask

How do I expose Docker container ports?

Need of exposing ports. In order to make a port available to services outside of Docker, or to Docker containers which are not connected to the container's network, we can use the -P or -p flag. This creates a firewall rule which maps a container port to a port on the Docker host to the outside world.

Does Docker compose expose ports?

Docker Compose exposes all specified container ports, making them reachable internally and externally from the local machine. Once again, in the PORTS column, we can find all the exposed ports. The value to the left of the arrow shows the host address where we can reach the container externally.

How does Docker exposing ports work?

What Is Docker Expose Port? This tells Docker your webserver will listen on port 80 for TCP connections since TCP is the default. For UDP, specify the protocol after the port. For more than one port, you can list EXPOSE more than once.


1 Answers

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"
like image 83
Ayushya Avatar answered Oct 14 '22 14:10

Ayushya