在docker容器中运行Haproxy
我试图从haproxy图像创建Docker容器,但遇到了一些问题。我按照教程的说明创建了一个包含在docker容器中运行Haproxy,docker,terminal,haproxy,Docker,Terminal,Haproxy,我试图从haproxy图像创建Docker容器,但遇到了一些问题。我按照教程的说明创建了一个包含 FROM haproxy:1.7 COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg 然后我运行docker build-t my haproxy.一切看起来都很好,但是当我运行docker run-it--rm--name haproxy语法时,请检查我的haproxy-haproxy-c-f/usr/local/etc/haproxy/h
FROM haproxy:1.7
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg
然后我运行docker build-t my haproxy.
一切看起来都很好,但是当我运行docker run-it--rm--name haproxy语法时,请检查我的haproxy-haproxy-c-f/usr/local/etc/haproxy/haproxy.cfg来测试配置文件,我得到以下错误`s
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:7] : cannot find user id for 'haproxy' (0:Success)
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:8] : cannot find group id for 'haproxy' (0:Success)
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:32] : error opening file </etc/haproxy/errors/400.http> for custom error message <400>.
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:33] : error opening file </etc/haproxy/errors/403.http> for custom error message <403>.
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:34] : error opening file </etc/haproxy/errors/408.http> for custom error message <408>.
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:35] : error opening file </etc/haproxy/errors/500.http> for custom error message <500>.
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:36] : error opening file </etc/haproxy/errors/502.http> for custom error message <502>.
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:37] : error opening file </etc/haproxy/errors/503.http> for custom error message <503>.
[ALERT] 114/152637 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:38] : error opening file </etc/haproxy/errors/504.http> for custom error message <504>.
[ALERT] 114/152637 (1) : Error(s) found in configuration file : /usr/local/etc/haproxy/haproxy.cfg
[ALERT] 114/152637 (1) : Fatal errors found in configuration.
每当我拉动官方的Haproxy容器时,我都看不到Haproxy用户/组。实际上,我为haproxy定制图像的全部原因就是添加它们
RUN addgroup -g 1000 haproxy && \
adduser -u 1000 -G haproxy -h /app -D haproxy
将用户和组从haproxy更改为root。它会起作用的
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
stats timeout 30s
user root
group root
daemon
在全局部分添加这两行
user haproxy
group haproxy
在“默认值”部分删除或注释此行
#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
#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