如何从Docker容器保存日志文件? [英] How to save log files from docker container?

查看:842
本文介绍了如何从Docker容器保存日志文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在docker-machine上运行的weblogic容器(正在使用docker toolbox在Windows 7上运行),并希望将日志从容器自动保存到Windows机器。

I have a weblogic container running on docker-machine( which is running on Windows 7 using docker toolbox) and want to save the logs from the container automatically to the windows machine.

我知道我可以使用 docker cp 命令,但是不必每次都将日志记录到Windows中机器,是否有更好的方法将日志从容器保存到Windows机器上的文件夹?

I know that I can use the docker cp command but, instead of coping the logs every time to the windows machine, is there a better way to save the logs from the container to a folder on windows machine?

推荐答案

请参见 Docker日志记录策略,其中介绍了不同的方法。

推荐的一种是通过 Docker日志记录驱动程序进行记录。

配置日志记录驱动程序

See "Docker Logging Strategies", which illustrates different methods.
The recommended one is logging via the Docker Logging Driver.
See more at "Configure logging drivers"

处理容器中的日志记录的更好方法,然后您可以通过数据卷容器

As shown in "Better ways of handling logging in containers", you can then link the log folder with an host folder through a data volume container.

# docker run -ti -v /dev/log:/dev/log fedora sh

这篇关于如何从Docker容器保存日志文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆