title: Docker-compose multiple ports expose
body: <p>My question is about expose multiple ports in one line from an <code>ENV</code> variable example, and these ports are not sequential, the same ports from host are going to be the same on container.</p>
  <pre class="lang-sh prettyprint-override"><code>PORTS=80
  PORTS=80,443
  PORTS=80 443
  </code></pre>
  <p>And expose them in <code>docker-compose</code>.</p>
  <p>according to <a href="https://docs.docker.com/compose/compose-file/#ports" rel="nofollow noreferrer">docs</a>, you can do.</p>
  <pre><code>ports:
   - &quot;3000&quot;
   - &quot;3000-3005&quot;
   - &quot;8000:8000&quot;
   - &quot;9090-9091:8080-8081&quot;
   - &quot;49100:22&quot;
   - &quot;127.0.0.1:8001:8001&quot;
   - &quot;127.0.0.1:5000-5010:5000-5010&quot;
   - &quot;6060:6060/udp&quot;
  </code></pre>
  <p>But i would like to do it another variable way</p>
  <pre><code>ports:
    - ${PORTS}:${PORTS}
  #Sometimes this will be 
  ports:
    - 80:80
  
  #Other times this will be
  ports:
    - 80,443:80,443 # Is this possible?
  ports:
    - 80-443:80-443 # Don't want this because will export all the ports between
  ports:
    - 80 443:80 443 # I think this is wrong syntax
  </code></pre>
  <p>Any clue or any other idea?</p>