我正在尝试使Varnish容器作为多容器Docker环境的一部分运行。
我使用https://github.com/newsdev/docker-varnish作为基础。
我的Dockerfile看起来像:
FROM newsdev/varnish:4.1.0
COPY start-varnishd.sh /usr/local/bin/start-varnishd
ENV VARNISH_VCL_PATH /etc/varnish/default.vcl
ENV VARNISH_PORT 80
ENV VARNISH_MEMORY 64m
EXPOSE 80
CMD [ "exec /usr/local/sbin/varnishd -j unix,user=varnishd -F -f /etc/varnish/default.vcl -s malloc,64m -a 0.0.0.0:80 -p http_req_hdr_len=16384 -p http_resp_hdr_len=16384" ]
当我将其作为docker-compose安装程序的一部分运行时,我得到:
ERROR: for eventsapi_varnish_1 Cannot start service varnish: oci runtime error: container_linux.go:262: starting container process caused "exec: \"exec /usr/local/sbin/varnishd -j unix,user=varnishd -F -f /etc/varnish/default.vcl -s malloc,64m -a 0.0.0.0:80 -p http_req_hdr_len=16384 -p http_resp_hdr_len=16384\": stat exec /usr/local/sbin/varnishd -j unix,user=varnishd -F -f /etc/varnish/default.vcl -s malloc,64m -a 0.0.0.0:80 -p http_req_hdr_len=16384 -p http_resp_hdr_len=16384: no such file or directory"
如果尝试,我会得到相同的结果
CMD ["start-varnishd"]
(因为它在基本newsdev/docker-varnish中)
或者
CMD [/usr/local/bin/start-varnishd]
但是,如果我直接在容器上运行bash shell:
docker run -t -i eventsapi_varnish /bin/bash
然后从那里运行varnishd命令,varnish可以正常启动(并且开始提示它显然找不到Web容器)。
我究竟做错了什么?找不到什么文件?再次直接环顾正在运行的容器,似乎Varnish是它认为应该的位置,VCL文件是它认为应该的位置...阻止它在docker-compose中运行的原因是什么?
谢谢!
最佳答案
我没有弄清楚为什么我会收到这个错误,但是通过使用(更新的?) fork: https://hub.docker.com/r/tripviss/varnish/ 来“修复”它。我的 Dockerfile 现在只是:
FROM tripviss/varnish:5.1
COPY default.vcl /usr/local/etc/varnish/
关于docker-compose - docker varnish cmd 错误 - 没有这样的文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45977237/