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

标签 amazon-web-services docker haproxy

我是 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/

相关文章:

amazon-web-services - 用于 eu-west-1 中资源的 us-east-1 中的 Terraform AWS ACM 证书

linux - 为什么我挂载的 docker volume 文件会变成容器内的文件夹?

docker - 如何将多行 docker 日志组合成一个流畅事件

http - 负载平衡 Web 套接字和长轮询

ios - 如何从 Amazon S3 下载 - iOS

r - 如何在 EC2 上运行 R 版本 > 3 或更新 Debian

python - 在 EMR 集群上安装 pandas

angular - Docker 中的 Protractor 测试 - 在 jasmine.DEFAULT_TIMEOUT_INTERVAL 指定的超时内未调用异步回调

ubuntu - 是否有任何 HAProxy 负载平衡算法仅将连接路由到一台服务器?

tcp - 使用 HAProxy 负载平衡 TCP