I'm running a .NET Core application in a Linux container.
The container runs fine locally, but when run in Azure Container Instances, it immediately stops.
The container's log file is shown below (retrieved using Get-AzContainerInstanceLog
):
failed to open log file "/var/log/pods/336d7870-5a8e-11e9-925e-000d3a0ddc4a/test-1_0.log":
open /var/log/pods/336d7870-5a8e-11e9-925e-000d3a0ddc4a/test-1_0.log: no such file or directory
EDIT:
I've never come across the mentioned file or the pods
path before (/var/log/pods/336d7870-5a8e-11e9-925e-000d3a0ddc4a/test-1_0.log
), and I have no idea what part of the OS and/or Docker needs it.
The log file and path isn't something that's used by my application running inside the container (it logs directly to the console, and as mentioned runs fine in a Linux container on my local Docker for Windows installation).
Google says it might be related to Kubernetes, but I'm not using Kubernetes "actively" (i.e. it might be used by Azure Container Instances under the covers, but it's not something that I as a user of ACI am aware of). Sorry for the unclear error description, I'll try to rephrase it.
The issue was that I was trying to pass in a command line argument to the container, which didn't work out in Azure.
I switched from using command line args to environment variables, and everything worked like magic.
So for me, this error occured when the container failed to start.
A better error description was provided, hiding in plain sight in one of the tabs/blades in the Azure Portal.
In my case, I had previously installed tini
and set the entrypoint in the Dockerfile to /sbin/tini --
. Upon doing so, it's acceptable to set the Dockerfile's CMD to a basic string without any quotes, such as CMD java -jar myapp.jar
However in Azure, you MUST set the command as an array of string segments:
in YAML: command: ["java", "-jar", "myapp.jar"]
Once I did this, the error above ("failed to open log file") disappeared and my container started successfully.
Azure reference
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