Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

422
Vistas
Docker compose bind failed: port is already allocated

I have been trying to get a socketio server moved over from EC2 to Docker.

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.

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:

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?

2. Getting "Bind for 0.0.0.0:8080 failed: port is already allocated".

DockerFile

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"]

Docker-Compose.yml

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 && node server.js'
    echo 'ready'
over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

  1. Getting "Bind for 0.0.0.0:8080 failed: port is already allocated".

you have duplicated port allocations.

  1. when not specifying a connection type, the port defaults to tcp: meaning "0.0.0.0:8080:8080" and "0.0.0.0:8080:8080/tcp" both trying to bind to the same port and hence your error.

  2. since docker uses 0.0.0.0 for default binding, same applies to "8080:8080/tcp" and "0.0.0.0:8080:8080/tcp" - you have no need in both of them.

therefore, you can shrink your ports section to:

   ports:
    - "8080:8080"
    - "8080:8080/udp"

I am not sure what the service should be called

it is completely up to you. usually services are named after their content, or role in the network, such as nginx_proxy laravel_backend etc. so node_app sounds good to me, app is also ok in small networks, src doesnt appear to have any meaning but again - it is just some identifier for your service, without any additional effect.

over 4 years ago · Santiago Trujillo Denunciar

0

You are just running another container on the same port. You can view it by docker ps and stop it by docker stop [CONTAINER ID].

over 4 years ago · Santiago Trujillo Denunciar

0

you just need to open docker.yml file and change your port address.....this happen for me because already that container was used by my company another member

example from 0.0.0.0:80==>0.0.0.0:8000 and also port from ports:- 80/80 to ports:- 8000:8000

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda