How to log container in docker swarm mode

旧街凉风 提交于 2019-12-23 07:03:46

问题


Is there a way to log the containers which are created with the docker service create in docker swarm mode?


回答1:


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:

Update: docker logs service is now a standard feature of docker >= 17.06. https://docs.docker.com/engine/reference/commandline/service_logs/




回答2:


The feature is not yet implemented. As @ronkot said, you have to figure out which node is running your service instance and connect directly to it.

Even if the feature will probably be implemented in the future, I strongly advice you to start to play with a Docker logging drivers in order to centralize all the logs of your cluster. Here is more information: https://docs.docker.com/engine/admin/logging/overview/

Fo example, the gelf driver is perfect if you want to use something like Logstash + Kibana :-)



来源:https://stackoverflow.com/questions/37940360/how-to-log-container-in-docker-swarm-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!