How find file in Docker?
This is my Dockerfile:
I’m having trouble with the
programminglanguage.js
file. This file contains master data, which my ASP.NET Core app uses during initialization to seed data into the database migration. Everything works fine in my development environment, but when I run the project in a Docker environment, the file can't be found.
When I run docker compose build
, the service builds successfully. However, when the project runs in Docker, I encounter the following error:
Here’s the code I’m using to read the file for seeding during migration:
In Docker, the issue seems to stem from the relative file path not being resolved correctly. I’d appreciate any help in resolving this so the app can find the file in the Docker environment.5 Replies
@TotechsStrypper Set the file to copy to the output dir on build, then Path.Combine the filename with
AppContext.BaseDirectory
.
From your Dockerfile, COPY --from=build /app/src/out .
, only the publish output has been copied into your final container, which doesn't include that js file.
(Also, is it actually javascript, or just json?)my bad it's a json file not a js file
solution
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•3mo ago
Message Not Public
Sign In & Join Server To View