title: Docker compose bind failed: port is already allocated
body: <p>I have been trying to get a socketio server moved over from EC2 to Docker.</p>
  
  <p>I have been able to connect to the socket via a web (http) client, but connecting directly to the socket via iOS or Android seems to be impossible.</p>
  
  <p>I read one of the issues can be the ports exposed are not actually published when using Docker. Since our mobile apps currently connect on port 8080 on our classic EC2 instance. I setup a docker-compose.yml file to try and open all ports and communication protocals, but I am two issues:</p>
  
  <p><strong>1. I am not sure what the service should be called so I went with "src" (see DockerFile below). But wondering if it should be app since server file is app.js?</strong></p>
  
  <p><strong>2. Getting "Bind for 0.0.0.0:8080 failed: port is already allocated".</strong></p>
  
  <p>DockerFile</p>
  
  <pre><code>FROM ubuntu:14.04
  
  ENV DEBIAN_FRONTEND noninteractive
  
  RUN mkdir /src
  ADD package.json /src
  
  RUN apt-get update
  RUN apt-get install --yes curl
  RUN curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
  RUN apt-get install --yes nodejs
  RUN apt-get install --yes build-essential
  
  RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
  
  
  
  RUN cd /src; npm install
  RUN npm install --silent socket.io@0.9.14
  
  
  WORKDIR /src
  
  
  
  
  # Bundle app source
  # Trouble with COPY http://stackoverflow.com/a/30405787/2926832
  COPY . /src
  
  ADD app.js /src/
  
  
  EXPOSE 8080
  
  CMD ["node", "/src/app.js"]
  </code></pre>
  
  <p>Docker-Compose.yml</p>
  
  <pre><code>src:
    build: .
    volumes:
      - ./:/src
    expose:
      - 8080
    ports:
      - "8080"
      - "8080:8080/udp"
      - "8080:8080/tcp"
      - "0.0.0.0:8080:8080"
      - "0.0.0.0:8080:8080/tcp"
      - "0.0.0.0:8080:8080/udp"
    environment:
      - NODE_ENV=development
      - PORT=8080
    command:
      sh -c 'npm i &amp;&amp; node server.js'
      echo 'ready'
  </code></pre>