在 Dockerfile 中使用这样的东西会有多糟糕:
ENTRYPOINT node . | tee >(send_logs_to_elastic_search)
大多数日志记录解决方案都需要一些非常讨厌的配置。以上将是我们以编程方式捕获日志并编写我们自己的胶水代码的一种方式。
上述解决方案的主要问题是CMD
参数不会附加到node
过程中?我假设他们会被追加到tee
流程中?像这样的东西:
docker run foo --arg1 --arg2
我假设那看起来像:
node . | tee >(send_logs_to_elastic_search) --arg1 --arg2
有人知道吗?
另一个潜在的问题是您的容器的可配置性较低,它被“硬编码”以将日志发送到send_logs_to_elastic_search
进程。