title: Docker-compose port range forward
body: <p>The documentation is really lacking here.</p>
  
  <pre><code>ports:
    - "20000-20100"
  </code></pre>
  
  <p>works fine for one port (just "20000" does not work tho. It seemingly binds to a random port above 40k somewhere), but I can't find a reliable way to forward a range of ports instead of just one.</p>
  
  <pre><code>- "20000-20100"
  - "10000-10100:20000-20100"
  - "20000-20100:20000-20100"
  </code></pre>
  
  <p>None of these works</p>
  
  <p>I have also exposed 20000-30000 in the Dockerfile, but I'm under impression that this shouldn't really matter. Am I being stupid here? This seems like such an easy thing, but I've been hammering for hours now unable to get the connections working.</p>
  
  <p>Edit:</p>
  
  <p>Using - "20000-20010" exposes these ports:</p>
  
  <p>0.0.0.0:43809->20000/tcp, 0.0.0.0:43808->20001/tcp, 0.0.0.0:43807->20002/tcp, 0.0.0.0:43806->20003/tcp, 0.0.0.0:43805->20004/tcp, 0.0.0.0:43804->20005/tcp, 0.0.0.0:43803->20006/tcp, 0.0.0.0:43802->20007/tcp, 0.0.0.0:43801->20008/tcp, 0.0.0.0:43800->20009/tcp, 0.0.0.0:43799->20010/tcp</p>
  
  <p>Using - "20000-20010:20000-20010" exposes these ports:</p>
  
  <p>0.0.0.0:20000-20010->20000-20010/tcp</p>
  
  <p>Which seems correct, but I'm unable to actually make any connections to them.</p>
  
  <p>Edit2: Docker-compose</p>
  
  <pre><code>version: '3.2'
  services:
    sshd:
      build: .
      ports:
        - "23:22"
        - "20000-20010:20000-20010"
      environment:
        REDIS_ADDRESS: redis
        DEBUG: 'sshd:*,ioredis:*'
    web:
      image: controller_web
      ports:
        - target: 3000
          published: 3000
          protocol: tcp
          mode: host
      environment:
        REDIS_ADDRESS: redis
        DEBUG: 'sshd:*,ioredis:*'
    redis:
      image: "redis"
  </code></pre>
  
  <p>Dockerfile</p>
  
  <pre><code>FROM node:alpine
  
  # add openssh and clean
  RUN apk add --update openssh \
  &amp;&amp; rm  -rf /tmp/* /var/cache/apk/*
  
  RUN mkdir -p /usr/src/app
  WORKDIR /usr/src/app
  
  ARG NODE_ENV
  ENV NODE_ENV $NODE_ENV
  COPY package.json /usr/src/app/
  
  RUN apk add --no-cache --virtual .gyp \
      python \
      make \
      g++
  
  RUN npm install &amp;&amp; npm cache clean --force
  COPY . /usr/src/app
  
  #make sure we get fresh keys
  RUN rm -rf /etc/ssh/ssh_host_rsa_key /etc/ssh/ssh_host_dsa_key
  
  EXPOSE 22
  EXPOSE 20000-30000
  ENTRYPOINT ["sh", "entrypoint.sh"]
  CMD ["npm", "start"]
  </code></pre>