Skip to content

Usersecrets in Docker container don't work when USER app set #97647

Open
@penfold

Description

@penfold

Description

In .net 7, we didn't need to use USER app in the docker file.

Using the mount documented mount: $(AppData)/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro

The secrets.json would load for local development debugging.

In .net 8, we add USER app.

Now, the secrets.json isn't loaded. When setting AddUserSecrets(optional: false) we see that get an exception:

System.IO.FileNotFoundException: 'The configuration file 'secrets.json' was not found and is not optional. The expected physical path was '/app/secrets.json'.'

at Microsoft.Extensions.Configuration.FileConfigurationProvider.Load(Boolean reload)
at Microsoft.Extensions.Configuration.ConfigurationManager.AddSource(IConfigurationSource source)
at Microsoft.Extensions.Configuration.ConfigurationManager.Microsoft.Extensions.Configuration.IConfigurationBuilder.Add(IConfigurationSource source)
at XXXXXX.Containers.Helpers.WebAppBuilderExtensions.ConfigureWebAppBuilder(WebApplicationBuilder builder, Boolean isInternal) in XXXXXXXX

If I comment out the USER app line in my docker file, then it loads correctly.

What do I need to set the linux mount path to for this to work? Or does this need a change in the PathHelper?

https://github.com/dotnet/runtime/blob/742039fd508eb451c0048527bf307125e9572b43/src/libraries/Microsoft.Extensions.Configuration.UserSecrets/src/PathHelper.cs

Reproduction Steps

See above

Expected behavior

See above

Actual behavior

See above

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions