10

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

2
  • 1
    Just totally remove your local rabbitmq or change the port it listens to, or change the port your map it on from your container. Commented Dec 19, 2019 at 16:01
  • 1
    @Zeitounator: thank you for your hints. I've edited my question with more infos. If you make your comment as an answer I accept it! Commented Dec 19, 2019 at 16:29

1 Answer 1

4

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.
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much! Just curios, how can I find the process that was using the port 5672 besides rabbitmq?
Well you actually found it with your above commands. It is rabbitmq running on localhost.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.