Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker container fails because service rabbit failed programming external connectivity on endpoint encoder_rabbit_1

Tags:

docker

it is some months that my docker container fails to build up due to the error below:

ERROR: for rabbit  Cannot start service rabbit: driver failed programming external connectivity on endpoint encoder_rabbit_1 (e9fa1caaf9b8cc57e0a1480cb50b17d0afb276d74471fca9fec922ddc559b1b2): Error starting userland proxy: listen tcp 0.0.0.0:5672: bind: address already in use

To "solve" the issue I do:

$> sudo lsof -i tcp:5672

and I get:

COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
beam.smp 1313 rabbitmq   54u  IPv6  27235      0t0  TCP *:amqp (LISTEN)

then:

$> sudo kill -9 1313

By killing rabbitmq process, I can build up the containers:

$> docker-compose up -d --build --force-recreate

Is there anything I can do to avoid this error from appearing without killing everytime the rabbitmq process?

Thank you for your help

EDIT 1: Following the comment by Zeitounator, I post below the docker-compose.yml:

version: '2.1'
services:
  files:
    image: busybox
    volumes:
      - ./file/input:/file/input
      - ./file/output:/file/output

  grafana:
    image: grafana/grafana:5.1.0
    ports:
      - 3000:3000
    volumes:
      - ./prometheus/grafana/:/etc/grafana/provisioning/
    environment:
      - GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource
      - GF_AUTH_BASIC_ENABLED=false
    depends_on: 
      - prometheus

  prometheus:
    image: prom/prometheus
    volumes:
      - ./prometheus/prometheus.yml:/etc/prometheus/prometheus.yml
    ports: 
      - 9090:9090

  aggregatore:
    build: aggregatore/.
    volumes:    
      - ./aggregatore:/src
    volumes_from: 
      - files
    ports:
      - 8000:8000
    command: ["python", "/src/main.py"]    
    depends_on: 
      rabbit:
        condition: service_healthy

  classificatore:
    build: classificatore/.
    volumes:    
      - ./classificatore:/src
    volumes_from: 
      - files
    ports: 
      - 8080:5000      
    command: ["python", "/src/main.py"]
    depends_on: 
      rabbit:
        condition: service_healthy

  mpeg-pre-encoder:
    build: mpeg-pre-encoder/.
    volumes:
      - ./mpeg-pre-encoder:/src
      - ./gabac_encoder:/src/gabac_encoder
    volumes_from: 
      - files    
    depends_on: 
      rabbit:
        condition: service_healthy

  rabbit:
    image: rabbitmq
    ports:
      - 5672:5672
    healthcheck:
      test: ["CMD", "rabbitmqctl", "cluster_status"]
      interval: 5s
      timeout: 2s
      retries: 20

I have changed the rabbit ports to

ports:
  - 7000:7000

and it did the trick!

Since I'm not at all an expert on this subject and I did not write the .yml file, how is that rabbit made my container fails if only rabbitmq was using that port? In the .yml I could not find any other process mapping on that port.. I guess I'm missing some steps

like image 826
user123892 Avatar asked Dec 19 '19 15:12

user123892


People also ask

How do I shut down docker?

Note that pressing `Ctrl+C` when the terminal is attached to a container output causes the container to shut down.


1 Answers

The base problem is that you are mapping a port from a docker service to port 5672 on your localhost and it is already taken. 3 solutions:

  • Remove the software using the 5672 port (i.e. rabbitmq running on localhost)
  • Change the port used by rabbitmq on localhost so your can map 5672 without error
  • Change the port you map so that it does not conflict with an existing one.
like image 66
Zeitounator Avatar answered Sep 29 '22 16:09

Zeitounator