如何访问Docker容器的Windows事件日志 [英] How do I access Windows eventlog of a Docker container
本文介绍了如何访问Docker容器的Windows事件日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从主机访问Microsoft Docker容器的Windows事件日志?
How do I access the Windows Event Log of a Microsoft Docker container from the host?
我在Windows Server 2016下有一个Docker容器。
I have a docker container under Windows Server 2016.
容器基于图像:microsoft / iis
The container is based on image: microsoft/iis
我可以通过以下方式获取容器的ip地址:
I can get the ip address of the container with:
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" my-running-site
如何通过Windows主机上的事件查看器连接到它?
How can I connect to it via the Event Viewer on the windows host?
推荐答案
为容器创建 powershell会话
docker exec -it <container_id> powershell
然后从容器中获取最新事件日志
Get-Eventlog -newest 20 application
上面的命令将帮助您找到索引,
Above command will help you to find the index,
(Get-Eventlog -index xxx application).message
这篇关于如何访问Docker容器的Windows事件日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文