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

4

6

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.

Halfmast answered 26/10, 2015 at 6:0 Comment(0)
H
4

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

Halfmast answered 26/10, 2015 at 10:20 Comment(6)
First I remove the haproxy command from the dockerfile. >> so do you create a new docker fileUnivocal
@naveen23 Yes, I modified it, I remove the call to start haproxy, if you look at the example in their repo, it is the last line. Then I start haproxy inside the container. The error that you will get is more detailed. But after finding the error "YOU NEED TO PUT THE daemon command BACK" or else, haproxy wont start.Halfmast
sorry sir, stilll not clear so .. docker run -d -v /path/to/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro haproxy:1.6 .. should be changed to ?Univocal
the dockerfile file should be changed. github.com/docker-library/haproxy/blob/master/1.4/Dockerfile . You need to build a new haproxy container, without the haproxy run command. CMD ["haproxy", "-f", "/usr/local/etc/haproxy/haproxy.cfg"] . This is only for DEBUGGING PURPOSE. This is not the actual solution for the ambiguous error message "No enabled listener found (check for 'bind' directives) ! Exiting" We could have different problem. This steps, would only let you see a more detailed error message.Halfmast
I had the issue running docker on windows (yeah, I know...) where the drives need to be shared before you can mount files as volumes. In the notification toolbar, find the docker icon, right click, click on settings and "Shared drives". tick as appropriate.Sneed
Hi, I getting the same error only difference is I'm using docker-compose.The complete post is #45574331 ....Can you please have a look at and help me with it...Thanks..Shealy
E
3

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.

Ene answered 26/10, 2015 at 8:12 Comment(1)
Thanks, it is not the problem. But it lead me to find the problem. By removing the daemon of haproxy in dockerfile. And running it manually inside docker container. The problem was my -v option in docker. It creates a directory instead of the .cfg fileHalfmast
H
1

I actually had to restart docker-machine (using OSX), otherwise every time I was running container with volume mount option (tried both absolute and relative paths) - it was mounting haproxy.cfg as a directory

Helbonia answered 8/7, 2016 at 22:35 Comment(0)
U
0
ls -l /etc/ssl/certs
ls -l /etc/ssl/private
chmod -r 400 /etc/ssl/private

perhaps also change the permissions on certs but I'm not sure. Starting up haproxy with globally readable ssl keys is a very bad security practice so they disable startup completely.

Unmake answered 10/6, 2016 at 14:50 Comment(1)
Good tip, but Andrew already posted the solution to his problem which was a bad host volume mapping (missing the path).Dior

© 2022 - 2024 — McMap. All rights reserved.