title: What's the docker-compose equivalent for docker run --publish-all?
body: <p>Docker provides the option <a href="https://docs.docker.com/engine/reference/commandline/run/" rel="nofollow noreferrer"><code>--publish-all</code></a> for <code>docker run</code>.</p>
  
  <pre><code>--publish-all , -P :        Publish all exposed ports to random ports
  </code></pre>
  
  <p>What would be the equivalent when using <code>docker-compose</code>? I've looked through the docker compose cli and yml file docs and can't find anything like that.</p>
  
  <p>For context, I am looking to do this with Elasticsearch as recommended by their documentation for deploying to production. <a href="https://www.elastic.co/guide/en/elasticsearch/reference/6.4/docker.html#_notes_for_production_use_and_defaults" rel="nofollow noreferrer">See #4 here</a>.</p>
  
  <blockquote>
    <p>The image exposes TCP ports 9200 and 9300. For clusters it is
    recommended to randomize the published ports with <code>--publish-all</code>,
    unless you are pinning one container per host.</p>
  </blockquote>