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

And*_*rez 6 proxy high-availability haproxy docker

我试图用docker运行haproxy.我按照这里的说明操作:

https://hub.docker.com/_/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
Run Code Online (Sandbox Code Playgroud)

我收到此错误:

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

我搜索了它,但我发现的唯一的东西是ha代理的源代码.

这是我的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
Run Code Online (Sandbox Code Playgroud)

编辑:顺便说一下,我也尝试将后端节点url更改为我的docker主机ip.但仍然没有运气.

And*_*rez 4

感谢@Michael 的评论。我能够解决这个问题。

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

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

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

我把它改成完整路径

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