Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

425
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda