从HAProxy泊坞窗容器安装haproxysockets

我想给同行容器访问/var/run/haproxy.sock 。 不幸的是,当我尝试通过与指定卷绑定安装来执行此操作时,会引发错误。 是可以与其他容器共享haproxy.sock ? 我想是这样,所以我想知道我在这里失去了哪一块。 可能是权利 – 但如何正确设置?

 worker1 | <7>haproxy-systemd-wrapper: executing /usr/local/sbin/haproxy -p /run/haproxy.pid -f /usr/local/etc/haproxy/haproxy.cfg -Ds worker1 | [ALERT] 182/075644 (6) : Starting frontend GLOBAL: error when trying to preserve previous UNIX socket [/var/run/haproxy.sock] worker1 | <5>haproxy-systemd-wrapper: exit, haproxy RC=1 

我有haproxy.cfg中的以下configuration:

 global maxconn 8204 tune.ssl.default-dh-param 2048 stats socket /var/run/haproxy.sock mode 660 level admin stats timeout 30s 

我使用docker-compose以swarm模式启动我的容器:

 version: '3.2' services: haproxy: image: haproxy:1.7.7 ports: - "80:80" - "443:443" volumes: - "/home/ubuntu/haproxy/haproxy.cfg:/usr/local/etc/haproxy/haproxy.cfg:ro" - "socket:/var/run/haproxy.sock:rw" ulimits: nofile: soft: 16479 hard: 16479 deploy: placement: constraints: - node.hostname==worker1 volumes: socket: {} 

命名卷只能是目录 ,而不能是单个文件。 因此,这一行;

 "socket:/var/run/haproxy.sock:rw" 

将试图在容器内的位置/var/run/haproxy.sock上安装目录(“套接字”卷)。

如果“haproxy.sock”的位置是可configuration的,你可以尝试类似的;

 "socket:/my-haproxy-socket-directory" 

(套接字本身将位于容器内的/my-haproxy-socket-directory/haproxy.sock中)