来自 HAProxy docker 容器的卷装载 haproxy 套接字
Volume mount haproxy socket from HAProxy docker container
我想授予对等容器对 /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 中有以下配置:
global
maxconn 8204
tune.ssl.default-dh-param 2048
stats socket /var/run/haproxy.sock mode 660 level admin
stats timeout 30s
我使用 docker-compose 以集群模式启动我的容器:
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
装载目录("socket" 卷)。
如果 "haproxy.sock" 的位置是可配置的,您可以尝试类似的东西;
"socket:/my-haproxy-socket-directory"
(套接字本身位于容器内的 /my-haproxy-socket-directory/haproxy.sock
)
我想授予对等容器对 /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 中有以下配置:
global
maxconn 8204
tune.ssl.default-dh-param 2048
stats socket /var/run/haproxy.sock mode 660 level admin
stats timeout 30s
我使用 docker-compose 以集群模式启动我的容器:
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
装载目录("socket" 卷)。
如果 "haproxy.sock" 的位置是可配置的,您可以尝试类似的东西;
"socket:/my-haproxy-socket-directory"
(套接字本身位于容器内的 /my-haproxy-socket-directory/haproxy.sock
)