How do I access the Windows Event Log of a Microsoft Docker container from the host?
I have a docker container under Windows Server 2016.
The container is based on image: microsoft/iis
I can get the ip address of the container with:
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" my-running-site
How can I connect to it via the Event Viewer on the windows host?
Run a Windows container using Windows Admin Center First, open the container host you want to manage, and in the Tools pane, select the Containers extension. Then, select the Images tab inside the Container extension under Container Host. In the Pull Container Image settings, provide the image URL and the tag.
You can run the container in foreground mode so you will able to see log. -it keep the container running in foreground as a result you will able to see your container logs. You will able to see live logs same like running application in terminal.
The docker logs command shows information logged by a running container. The docker service logs command shows information logged by all containers participating in a service. The information that is logged and the format of the log depends almost entirely on the container's endpoint command.
Create a powershell session for the container
docker exec -it <container_id> powershell
Then from the container, get the latest event logs
Get-Eventlog -newest 20 application
Above command will help you to find the index,
(Get-Eventlog -index xxx application).message
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With