Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

haproxy / docker No enabled listener found (check for 'bind' directives) ! Exiting

I am trying to run haproxy with docker. I followed the instructions here :

https://hub.docker.com/_/haproxy/

I was able to build the docker image but after trying to run it.

using

docker run -d --link another_container:another_container --name mc-ha -v haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro my_own_haproxy:latest

I get this error :

[ALERT] 298/054910 (1) : [haproxy.main()] No enabled listener found (check for 'bind' directives) ! Exiting.

I searched for it , but the only thing I found is the source code of ha proxy.

Here is my haproxy.cfg

global
    log /dev/log    local0
    log /dev/log    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

    # Default SSL material locations
    ca-base /etc/ssl/certs
    crt-base /etc/ssl/private

    # Default ciphers to use on SSL-enabled listening sockets.
    # For more information, see ciphers(1SSL).
    ssl-default-bind-ciphers kEECDH+aRSA+AES:kRSA+AES:+AES256:RC4-SHA:!kEDH:!LOW:!EXP:!MD5:!aNULL:!eNULL

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    timeout connect 5000
    timeout client  50000
    timeout server  50000
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend esNodes
    bind *:8091
    mode http
    default_backend srNodes

backend srNodes
    mode http
    balance roundrobin
    option forwardfor
    http-request set-header X-Forwarded-Port %[dst_port]
    http-request add-header X-Forwarded-Proto https if { ssl_fc }
    option httpchk HEAD / HTTP/1.1\r\nHost:localhost
    server web01 0.0.0.0:10903/project/es check

EDIT: Btw I also tried changing the backend node url to my docker host ip. But still no luck.

like image 853
Andrew James Ramirez Avatar asked Oct 26 '15 06:10

Andrew James Ramirez


2 Answers

Thanks to @Michael comment. I was able to solve the problem.

First I remove the haproxy command from the dockerfile. And then I run the haproxy command manually inside the container.

Voila! My config file is not a file. Its a directory. LOL

The problem is in my docker command -v.

I change it to full path

-v FULL_PATH/customhaproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg

like image 93
Andrew James Ramirez Avatar answered Sep 21 '22 20:09

Andrew James Ramirez


You will want to remove the daemon keyword from your docker file - docker needs a foreground process to be running otherwise docker will exit immediately.

I think the error message you are seeing is because docker exits quicker than haproxy binds to any ports.

like image 31
Michael Avatar answered Sep 19 '22 20:09

Michael