Hello! My use case is that I have a Discord bot written in discord.py that then uses docker.py to run the chat exporter through docker, have it output an archive through a volume to a local directory, then upload the archive onto another service, and delete the local version.
What I am struggling with is that last part. If I mount a local directory to /app/out, the output files have root ownership and cannot be deleted. I assume this is due to user inside the container being root. So I run it with the argument --user 1000 (the user id for my user on the server that is also running the python application), but then I get the following stack trace:
Exporting channel 'REDACTED / EXPUNGED'... System.UnauthorizedAccessException: Access to the path '/app/out/CHANNELID.xml' is denied.
---> System.IO.IOException: Permission denied
--- End of inner exception stack trace ---
at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode)
at System.IO.FileStream.OpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize)
at System.IO.File.Create(String path)
at DiscordChatExporter.Domain.Exporting.MessageExporter.CreateMessageWriter(String filePath, ExportFormat format, ExportContext context) in /src/DiscordChatExporter.Domain/Exporting/MessageExporter.cs:line 97
at DiscordChatExporter.Domain.Exporting.MessageExporter.GetWriterAsync() in /src/DiscordChatExporter.Domain/Exporting/MessageExporter.cs:line 57
at DiscordChatExporter.Domain.Exporting.MessageExporter.ExportMessageAsync(Message message) in /src/DiscordChatExporter.Domain/Exporting/MessageExporter.cs:line 65
at DiscordChatExporter.Domain.Exporting.ChannelExporter.ExportChannelAsync(ExportRequest request, IProgress`1 progress) in /src/DiscordChatExporter.Domain/Exporting/ChannelExporter.cs:line 56
at DiscordChatExporter.Domain.Exporting.ChannelExporter.ExportChannelAsync(ExportRequest request, IProgress`1 progress) in /src/DiscordChatExporter.Domain/Exporting/ChannelExporter.cs:line 40
at DiscordChatExporter.Domain.Exporting.ChannelExporter.ExportChannelAsync(ExportRequest request, IProgress`1 progress) in /src/DiscordChatExporter.Domain/Exporting/ChannelExporter.cs:line 62
at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.ExportAsync(IConsole console, Guild guild, Channel channel) in /src/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:line 56
at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.ExportAsync(IConsole console, Channel channel) in /src/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:line 63
at DiscordChatExporter.Cli.Commands.Base.ExportCommandBase.ExportAsync(IConsole console, String channelId) in /src/DiscordChatExporter.Cli/Commands/Base/ExportCommandBase.cs:line 69
at DiscordChatExporter.Cli.Commands.ExportChannelCommand.ExecuteAsync(IConsole console) in /src/DiscordChatExporter.Cli/Commands/ExportChannelCommand.cs:line 14
at CliFx.CliApplication.RunAsync(IReadOnlyList`1 commandLineArguments, IReadOnlyDictionary`2 environmentVariables)
Is there any solution such that I could get the archives out of the container in a way such that they are owned by a user other than root? (Yes I could probably just not use the docker method and use the CLI directly but the entire point of me using python is portability and also running it through docker adds to that portability)
Thanks for the help in advance, this project is really awesome 馃憤馃徎
Okay, nevermind, just had a random 3AM moment... Turns out the problem was that somehow the folder I was mapping to /app/out was created with root permissions... works now
Most helpful comment
Okay, nevermind, just had a random 3AM moment... Turns out the problem was that somehow the folder I was mapping to /app/out was created with root permissions... works now