未找到haproxy/docker启用的侦听器(检查';绑定';指令)!退出

未找到haproxy/docker启用的侦听器(检查';绑定';指令)!退出,proxy,docker,haproxy,high-availability,Proxy,Docker,Haproxy,High Availability,我正试着和docker一起经营haproxy。我按照这里的指示: 我能够构建docker映像,但在尝试运行它之后 使用 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 我得到这个错误: [ALERT] 298/054910 (1) : [haproxy.

我正试着和docker一起经营haproxy。我按照这里的指示:

我能够构建docker映像,但在尝试运行它之后

使用

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
我得到这个错误:

[ALERT] 298/054910 (1) : [haproxy.main()] No enabled listener found (check for 'bind' directives) ! Exiting.
我搜索了它,但我唯一找到的是ha proxy的源代码

这是我的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
ls -l /etc/ssl/certs
ls -l /etc/ssl/private
chmod -r 400 /etc/ssl/private

编辑:顺便说一句,我还尝试将后端节点url更改为我的docker主机ip。但是仍然不走运。

您需要从docker文件中删除
守护进程
关键字-docker需要一个前台进程才能运行,否则docker将立即退出


我认为您看到的错误消息是因为docker退出比haproxy绑定到任何端口都要快

感谢@Michael comment。我能解决这个问题


首先,我从dockerfile中删除haproxy命令。然后在容器内手动运行haproxy命令

瞧!我的配置文件不是一个文件。它是一个目录。哈哈

问题出在我的docker命令-v中

我将其更改为完整路径

-v完整路径/customhaproxy.cfg:/usr/local/etc/haproxy/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
ls -l /etc/ssl/certs
ls -l /etc/ssl/private
chmod -r 400 /etc/ssl/private

也许还会更改证书的权限,但我不确定。使用全局可读的ssl密钥启动haproxy是一种非常糟糕的安全做法,因此它们会完全禁用启动功能。

我实际上必须重新启动
docker机器(使用OSX),否则每次我都要使用卷装载选项运行
容器
(尝试绝对路径和相对路径)-它正在将haproxy.cfg安装为目录

谢谢,这不是问题所在。但这让我找到了问题所在。通过删除dockerfile中haproxy的守护进程。并在docker容器中手动运行它。问题是docker中的my-v选项。它创建一个目录而不是.cfg文件。首先,我从dockerfile中删除haproxy命令。>>那么您是否创建了一个新的dockerfile@naveen23是的,我修改了它,我删除了启动haproxy的调用,如果你看看他们回购协议中的例子,这是最后一行。然后我在容器内开始haproxy。您将得到的错误更详细。但是在发现错误“您需要将守护程序命令放回”之后,否则haproxy将无法启动。对不起,先生,我仍然不清楚。。docker run-d-v/path/to/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro-haproxy:1.6。。是否应更改为?dockerfile文件应更改。您需要在不使用haproxy run命令的情况下构建新的haproxy容器。CMD[“haproxy”、“-f”、“/usr/local/etc/haproxy/haproxy.cfg”]。这仅用于调试目的。对于不明确的错误消息“找不到已启用的侦听器(检查“绑定”指令)!正在退出”,这不是实际的解决方案。我们可能会遇到不同的问题。此步骤只会让您看到更详细的错误消息。我在windows上运行docker时遇到了问题(是的,我知道…),在windows上需要共享驱动器,然后才能将文件装载为卷。在通知工具栏中,找到docker图标,右键单击,单击设置和“共享驱动器”。根据需要勾选。提示很好,但Andrew已经发布了问题的解决方案,即主机卷映射错误(缺少路径)。