question

JakubNeruda-8656 avatar image
0 Votes"
JakubNeruda-8656 asked srbhatta-msft commented

Missing logs for Windows Nano Server image on Azure Container Instances

When I use Azure Portal GUI to create new Container Instance with ubuntu:latest image, default properties and starting command [ "/bin/bash", "-c", "echo hello" ], everything works fine. Container will start, print 'hello' and shuts down. I can then see the message in the logs and I can also read this message using az container logs command.

When I attempt to do the same with Windows container, using nanoserver:sac2016 (officially listed as supported: https://docs.microsoft.com/en-us/azure/container-instances/container-instances-faq#windows-server-2016-base-images) and starting command [ "cmd", "/c", "echo hello" ], it runs with success, but there are no logs to be found and az container logs also prints nothing.

If I try to locally perform docker run, it behaves as expected, even if redirection of stdout is performed:

> docker run mcr.microsoft.com/windows/nanoserver:sac2016 cmd /c echo hello >log.txt
> type log.txt
hello

Is there some extra configuration that has to be performed for Windows images in order for them to correctly produce logs?

NOTE: This question is minimum reproducible for the issue, I have the same problem when I create the container instance by some other mean like C# code.

azure-container-instanceswindows-server-nano
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

srbhatta-msft avatar image
0 Votes"
srbhatta-msft answered JakubNeruda-8656 commented

Hello @JakubNeruda-8656 ,

Thanks for reaching out to Microsoft QnA.
Firstly, apologies for the delay in response. I understand you want the container to produce logs. For that, you need to stream to its standard out with az container attach command. This command streams STDOUT and STDERR to your local console. Please find the command syntax below.

 az container attach --resource-group <resourcegroupname> --name <containername>

Reference link: https://docs.microsoft.com/en-us/azure/container-instances/container-instances-get-logs
I hope this helps. Please feel free to reach out for any queries.


Please don't forget to accept as answer and upvote if you think my response was helpful, so that it can help others in the community looking for help on similar issues.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello @srbhatta-msft, I've tried az container attach, but it does not help in this case as it doesn't receive any stdout/stderr as well.

I suspect this is bug with the container image itself. When I tried nanoserver images nanoserver:2004 or nanoserver:1809 and those produced logs as expected. However, only sac2016 has powershell installed. I ended up migrating to image mcr.microsoft.com/powershell:lts-nanoserver-1809 which can be deployed to Azure Container Instances, has Powershell and has working logging.

Honestly - documentation for this is not perfect, it would be nice if this page https://docs.microsoft.com/en-us/azure/container-instances/container-instances-faq had mentioned nanoservers with Powershell. I've found questions from many people who were installing powershell into nanoserver by themselves because they didn't know about this particular container registry.

Anyways, I am closing this question since I've found an acceptable workaround.



0 Votes 0 ·
JakubNeruda-8656 avatar image
1 Vote"
JakubNeruda-8656 answered srbhatta-msft commented

If anyone stumbles to similar problems, here are two workarounds:

  • Use nanoserver:2004 or nanoserver:1809 (or anything based off Windows Server 2019), these can be deployed to Azure and their logging works

  • If you also need Powershell, use mcr.microsoft.com/powershell instead of mcr.microsoft.com/windows/nanoserver. There are builds of nanoserver with powershell inside, for example: mcr.microsoft.com/powershell:lts-nanoserver-1809. Be aware that powershell executable is called pwsh.exe, not powershell.exe.

...and apparently I cannot tag my own answer as an accepted one...






· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HI @JakubNeruda-8656 , Thank you for sharing the workaround. Yes, due to recent changes in Microsoft QnA, the original poster will not be able to accept their own answer, but I have upvoted your answer so that it benefits the community looking for help on similar issues. Thanks!

1 Vote 1 ·