How can I expose all ports in docker-compose.yml instead of one port?

We start the container using “docker run -d -P --link hub-name:hub selenium/node-chrome-debug”. In this command -P flag automatically maps its port to hots port. How I can do that using docker-compose.yml

In docker-compose file
- 8082:80
Expose a port 80 For Outside and 8082 For inside

1 Like

The docker-compose.yml specification does not offer a setting to publish all exposed ports from the image without publishing them one by one.

The only way to bind all ports with docker-compose is to use the host network for your container:
add network: host to your service declaration. This will only work with docker-compose (!), swarm deployments require a different approch to make a container use the host network.

1 Like

Thanks for the info.