加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

亚马逊网络服务-Docker容器中的haproxy

发布时间:2020-12-16 03:22:50 所属栏目:安全 来源:网络整理
导读:我是docker和haproxy的新手..我尝试遵循官方docker hub repo中的示例. 所以,我有Dockerfile FROM haproxy:1.5COPY haproxy.cfg /usr/local/etc/haproxy/haproxy.cfg 和简单的haproxy配置(我希望将本地调用重定向到我的EB实例) global # daemon maxconn 256de

我是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,它将终止并停止容器.

除非您在调试模式下运行,否则HAProxy不会产生任何输出,因此,运行附件并不十分重要.使用docker run -d< image>可能会有更好的时间,它将与容器分离并使其在后台运行.要停止它,请使用docker kill.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读