gpt4 book ai didi

amazon-web-services - docker容器中的haproxy

转载 作者:行者123 更新时间:2023-12-01 23:45:06 25 4
gpt4 key购买 nike

我是 docker 和 haproxy 的新手。我试图按照官方 docker hub repo 中的示例进行操作。 .

所以,我有 Dockerfile

FROM haproxy:1.5
COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg

和简单的 haproxy 配置(我希望将本地调用重定向到我的 EB 实例)
global
# daemon
maxconn 256

defaults
mode http
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms

frontend http-in
bind *:80
default_backend servers

backend servers
server server1 {my-app}.elasticbeanstalk.com:80 maxconn 32

构建并运行
$ docker build .
$ docker run --rm d4598bcc293f

容器启动并卡住,Ctrl+C 不会停止它。 “docker kill”只会有所帮助。

我的 EB 资源已启动并正在运行
$ curl {my-app}.elasticbeanstalk.com/status
{
"status": "OK"
}

但是本地调用失败
$ boot2docker ip
192.168.59.104

$ curl 192.168.59.104/status
curl: (7) Failed to connect to 192.168.59.104 port 80: Connection refused

我错过了什么或做错了什么?

谢谢!

UPDATE: I've found the problem with calls redirections. Wrong port number in haproxy.cfg.

But this problem still annoys me... Container starts and stucks, Ctrl+C doen't stop it. "docker kill" helps only.

最佳答案

如果您希望能够使用 control-c 退出,请执行 docker run -i <image> . -i意味着将输入传递给容器化程序,如果 HAProxy 获得一个 control-c,那么它将终止,这将停止容器。

除非您在 Debug模式下运行 HAProxy,否则它不会产生任何输出,因此运行附加功能并没有太大意义。您可能会在 docker run -d <image> 度过更好的时光,它将与容器分离并让它在后台运行。要停止它,请使用 docker kill .

关于amazon-web-services - docker容器中的haproxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29724029/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com