Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to the path '/app/ocelot.json' is denied #1955

Closed
MuhammadAshouri opened this issue Feb 5, 2024 · 1 comment · Fixed by #1227
Closed

Access to the path '/app/ocelot.json' is denied #1955

MuhammadAshouri opened this issue Feb 5, 2024 · 1 comment · Fixed by #1227
Assignees
Labels
Configuration Ocelot feature: Configuration merged Issue has been merged to dev and is waiting for the next release

Comments

@MuhammadAshouri
Copy link

MuhammadAshouri commented Feb 5, 2024

I'm using ocelot in dotnet 8
Running app on windows (self host) is totally fine
But when I run app in docker container I'm getting access denied in AddJsonFile
I've checked container folders and /app/ocelot.json is present (but it's read-only)

Here is my Program.cs

builder.Configuration
    .SetBasePath(environment.ContentRootPath).AddJsonFile("ocelot.json", false, true)
    .AddOcelot(environment)
    .AddEnvironmentVariables();
builder.Services
    .AddOcelot(configuration);

and even when I'm trying to remove read-only attribute I'm getting the same error

var file = new FileInfo("ocelot.json")
{
    IsReadOnly = false
};
file.CopyTo(Path.Combine(environment.ContentRootPath, "ocelot.json"), true);

I've already checked issues and haven't find the solution except this #1216 which seems like it isn't finished yet

Specifications

  • Version: 22.0.1
  • Platform: Docker (WSL)
  • Subsystem: Windows
@raman-m raman-m self-assigned this Feb 6, 2024
@raman-m raman-m added needs validation Issue has not been replicated or verified yet Configuration Ocelot feature: Configuration labels Feb 6, 2024
@raman-m
Copy link
Member

raman-m commented Feb 6, 2024

Hi Muhammad!
Welcome to Ocelot world! 🐯

I can't get it, is it a bug or do you ask the question "How to configure"?
What I see now is misconfiguration issue... Your Program.cs code is very short!

Please upload whole solution to GitHub for review, or attach more artifacts: JSON config, Ocelot Startup C# code, and Ocelot app logs with errors/exceptions.
Configuration feature docs:

  • Configuration, you have to read all subsections carefully
  • Routing, it helps to write correct route definition JSON

But when I run app in docker container I'm getting access denied in AddJsonFile

Yeap, setup of Docker environment is out of the scope of Ocelot. But, I agree that we don't have much documentation on how to properly run Ocelot in a Docker environment: Search for "docker".
Seems, we need to write more documentation for Docker. But for now, you could refer to Microsoft Learn docs looking for Kestrel & Docker articles.


I've checked container folders and /app/ocelot.json is present (but it's read-only)

This is Linux OS in Docker environment issue (WSL is Linux, aka Ubuntu Linux build). Please refer to Linux or Ubuntu documentation, or read more docs for WSL setup.
If you will still be sure that this Ocelot issue when can't write Ocelot file to Linux OS drive then let us know how we could fix this.

@ThreeMammals ThreeMammals locked and limited conversation to collaborators Feb 6, 2024
@raman-m raman-m converted this issue into discussion #1956 Feb 6, 2024
@raman-m raman-m added merged Issue has been merged to dev and is waiting for the next release and removed needs validation Issue has not been replicated or verified yet labels Mar 15, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
Configuration Ocelot feature: Configuration merged Issue has been merged to dev and is waiting for the next release
Projects
None yet
2 participants