title: Docker container fails because service rabbit failed programming external connectivity on endpoint encoder_rabbit_1
body: <p>it is some months that my docker container fails to build up due to the error below: </p>
  
  <pre><code>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
  </code></pre>
  
  <p>To "solve" the issue I do:</p>
  
  <pre><code>$&gt; sudo lsof -i tcp:5672
  </code></pre>
  
  <p>and I get:</p>
  
  <pre><code>COMMAND   PID     USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
  beam.smp 1313 rabbitmq   54u  IPv6  27235      0t0  TCP *:amqp (LISTEN)
  </code></pre>
  
  <p>then:</p>
  
  <pre><code>$&gt; sudo kill -9 1313
  </code></pre>
  
  <p>By killing <code>rabbitmq</code> process, I can build up the containers:</p>
  
  <pre><code>$&gt; docker-compose up -d --build --force-recreate
  </code></pre>
  
  <p>Is there anything I can do to avoid this error from appearing without killing everytime the rabbitmq process?</p>
  
  <p>Thank you for your help</p>
  
  <p><strong>EDIT 1:</strong>
  Following the comment by Zeitounator, I post below the <code>docker-compose.yml</code>:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>I have changed the rabbit ports to</p>
  
  <pre><code>ports:
    - 7000:7000
  </code></pre>
  
  <p>and it did the trick!</p>
  
  <p>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 </p>