如何在docker swarm模式下记录容器 [英] How to log container in docker swarm mode
问题描述
有没有一种方法可以记录使用 docker service create
在docker群模式下创建的容器?
Is there a way to log the containers which are created with the docker service create
in docker swarm mode?
推荐答案
最后,该功能已在docker 17.03中实现。您可以使用以下命令获取在不同/多个节点上运行的服务的日志:
Finally that feature has been implemented in docker 17.03. You can get the logs of a service running on different/multiple nodes with this command:
docker service logs -f {NAME_OF_THE_SERVICE}
您可以通过以下方式获取服务名称:
You can get the name of the service with:
docker service ls
这是一项实验功能(尚未投入生产),要使用该功能,您必须启用实验模式:
Note that this is an experimental feature (not production ready) and in order to use it you must enable the experimental mode:
更新: docker日志服务现在是docker> = 17.06的标准功能。
https://docs.docker.com/engine/reference/commandline / service_logs /
Update: docker logs service is now a standard feature of docker >= 17.06. https://docs.docker.com/engine/reference/commandline/service_logs/
这篇关于如何在docker swarm模式下记录容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!