Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when runnning Linux container in Azure Container Instances: failed to open log file "/var/log/pods/.../<container name>_0.log"

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.

like image 771
Uli Avatar asked Apr 09 '19 06:04

Uli


2 Answers

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.

like image 187
Uli Avatar answered Oct 16 '22 06:10

Uli


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

like image 43
ExactaBox Avatar answered Oct 16 '22 06:10

ExactaBox