What directory is writable in an aspire container? #4216
-
Hi folks, I really need a way to write a simple text file in my ApiService container. No matter what I try, it seems that after deployment to Azure the restricted 'app' user cant even create a txt file in its own directory, nor in the (usually globally-writable) Here's a screenshot the console of the aspire app in Azure. I try three times to test to see if I can write a text file:
Why?It's nearly impossible to debug a Linux-only, production-only, problem that is precompiled (i.e. not in my code, so I cant determine where to send the diagnostics). However, he upstream library author does make sure this output is available via TraceListener for this exact reason. So, here's what I'm using to try and get those traces: var logFilePath = "_traceoutput.log";
// Experimenting with this, it's not always here
File.SetUnixFileMode(logFilePath, UnixFileMode.UserRead | UnixFileMode.UserWrite);
// I need this
System.Diagnostics.Trace.Listeners.Add(new System.Diagnostics.TextWriterTraceListener());
System.Diagnostics.Trace.AutoFlush = true; If you have an alternate suggestion, say stream the traces somewhere else, I'm all-ears :)... but this no-root, and restricted app user is causing more problems right now. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
I do see Seq https://learn.microsoft.com/en-us/dotnet/aspire/logging/seq-component?tabs=package-reference as a production-worthy option, so I'll post it here. Though I am looking for a quick one-off instead of having to wire up an entire new service just for a one-time debugging experience. |
Beta Was this translation helpful? Give feedback.
-
You can do one of two things with non-root:
This makes the point to show the space that $ docker run --rm -u app --entrypoint bash mcr.microsoft.com/dotnet/aspnet:8.0 -c "cd && pwd"
/home/app |
Beta Was this translation helpful? Give feedback.
You can do one of two things with non-root:
/home/app
app
.This makes the point to show the space that
app
owns.$ docker run --rm -u app --entrypoint bash mcr.microsoft.com/dotnet/aspnet:8.0 -c "cd && pwd" /home/app