由于未知原因,在 Docker 容器中启动 Varnish 失败

由于未知原因,在 Docker 容器中启动 Varnish 失败

我正在尝试让 Varnish 在容器中运行,但遇到了一个奇怪的问题。如果我登录并从命令行执行,一切都会正常进行,但是当我尝试使用相同的命令从 Docker 运行它时,它似乎失败了(我猜它没有正确获取配置)。有什么想法吗?

$ docker run --add-host "web:127.0.0.1" -ti my-proxy /bin/bash
root@f81c7d3ca1c6:/# /usr/sbin/varnishd -F -f /etc/varnish/default.vcl -a :80 -T localhost:6082 -S /etc/varnish/secret -s malloc,256m
child (24) Started
Child (24) said Child starts
^CManager got SIGINT
Stopping Child
root@f81c7d3ca1c6:/# exit

$ docker run --add-host "web:127.0.0.1" my-proxy
WARNING: (-sfile) file size reduced to 0 (80% of available disk space)
child (14) Started
Pushing vcls failed:
CLI communication error (hdr)
Stopping Child
Child (14) died signal=6
Child (14) Panic message: Assert error in smf_open_chunk(), storage_file.c line 403:
  Condition(sz != 0) not true.
thread = (cache-main)
ident = Linux,4.0.9-boot2docker,x86_64,-sfile,-smalloc,-hcritbit,no_waiter
Backtrace:
  0x430935: /usr/sbin/varnishd() [0x430935]
  0x44b2cf: /usr/sbin/varnishd() [0x44b2cf]
  0x44b561: /usr/sbin/varnishd() [0x44b561]
  0x449a57: /usr/sbin/varnishd(STV_open+0x27) [0x449a57]
  0x42f74f: /usr/sbin/varnishd(child_main+0xbf) [0x42f74f]
  0x44255f: /usr/sbin/varnishd() [0x44255f]
  0x442e62: /usr/sbin/varnishd(MGT_Run+0x1d2) [0x442e62]
  0x40c2c0: /usr/sbin/varnishd(main+0x930) [0x40c2c0]
  0x7f9ccbc40ec5: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f9ccbc40ec5]
  0x40c644: /usr/sbin/varnishd() [0x40c644]


Child (-1) said Child starts
Child cleanup complete
manager dies

以下是 Docker 命令:

CMD ["/usr/sbin/varnishd", "-F", "-f", "/etc/varnish/default.vcl", "-a", ":80", "-T", "localhost:6082", "-S", "/etc/varnish/secret", "-s", "malloc,256m"]

答案1

这里的故障完全是 Docker 的问题,与 Varnish 完全无关。我进行了很多构建,结果发现问题是我的 inode 不足。

https://gist.githubusercontent.com/michaelneale/1366325a7737c4cb80b0/raw/4a61279d8498758111533589d1de648a9a31f691/docker-clean

运行这两个操作解决了我的问题。

相关内容