title: Docker Compose: Port mapping by selecting a random port within given port range
body: <p>One thing I am trying to accomplish is that I have a single port exposed from the container(8001).I want to map this container port with a host port. But I want make this host port as randomly selected port from a given port range(8081-8089). Below is the syntax</p>
  <pre class="lang-yaml prettyprint-override"><code>ports:
    - &quot;8081-8089:8001&quot;
  </code></pre>
  <p>If I use docker-compose v1.29.2 , its working as expected(Selecting single random port within given range). But when I try to use docker-compose v2 its not mapping a single port instead its running container on all ports of given range(8081-8089).</p>
  <p>I haven't been able to find a way to do this in the Docker documentation. Do we have any flag which enables this functionality in docker-compose v2? or is it not supported in docker compose v2?</p>