5

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.

Uli
  • 1,565
  • 14
  • 24
  • You can connect to the instance and check if it really misses the file. – Charles Xu Apr 09 '19 at 08:44
  • The file doesn't exist, and I have no idea what part of the OS and/or Docker needs it. Google says it might be related to Kubernetes, but I'm not using Kubernetes (although it's probably used by Azure Container Instances under the covers). Sorry for the unclear error description, I'll try to rephrase it. – Uli Apr 09 '19 at 09:41
  • 1
    Did you manage to figure out why? I am also having the same issue. – VisualBean May 23 '19 at 10:50
  • IIRC 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. I think that a better error description was provided, hiding in plain sight in one of the tabs/blades in the Azure Portal. – Uli May 23 '19 at 19:41

2 Answers2

3

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.

Uli
  • 1,565
  • 14
  • 24
1

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

ExactaBox
  • 3,235
  • 16
  • 27