-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
usersecrets are not accessible inside container for worker service project #36062
Comments
is this fixed? |
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label. |
Any news ? |
I am running into the same issue for a console app running in docker. Any news on this? |
There's no issue with the mount. The docker image default "Docker": {
"commandName": "Docker",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
} |
@wzchua, |
when you run the default aspnetcore project with docker. |
Having the same issue here. I can see the problem as explained by @wzchua is that my {
"profiles": {
"Iata.Verity.Service": {
"commandName": "Project",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
},
"dotnetRunMessages": "true"
},
"Docker": {
"commandName": "Docker",
"environmentVariables": {
"DOTNET_ENVIRONMENT": "Development"
}
}
}
} |
@angusmillar Not that it's a proper fix, but telling Docker directly about it seems to work. For example I have this in my environment:
- DOTNET_ENVIRONMENT=Development
volumes:
- "${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets/:ro" I also needed the volume definition as it wasn't being mapped by default. |
Closing since there seems to be a workaround |
Closing this issue is not proper. The Docker tooling should do the setup for user secrets automatically. Please reopen this. |
@MichaelSimons what are your thoughts here? |
cc @mthalman as well. |
This seems like a VS Docker Tools issue vs a runtime issue. I suggest opening an issue at https://github.com/microsoft/dockertools/issues. |
Closing as this is not a dotnet/runtime issue. If someone is blocked on the VS Docker Tools, please open an issue at https://github.com/microsoft/dockertools/issues. |
Describe the bug
The user secrets for a worker service are not accessible inside docker container.
To Reproduce
Steps to reproduce the behavior:
a. Package reference to
Microsoft.Extensions.Configuration.UserSecrets
as following<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.1" />
Because of this issue #2743
b. A volume mapping of the user secrets directory inside the container by adding following line to the property group -
<DockerfileRunArguments>-v "$(AppData)/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro"</DockerfileRunArguments>
Worker.cs
to access the user secrets -On powershell or command prompt, navigate to the project directory and add user secrets using the command -
dotnet user-secrets set "secretKey" "secretValue"
hit F5 with the Docker debug profile and monitor the output window. Notice that the value of the user secret is null.
Note: You can open the Containers window in the VS to check the file contents of the container.
If you check the path -
/root/.microsoft/usersecrets
you will notice the user-secrets directory withsecrets.json
inside it.Expected behavior
The output should print the value of the user-secret.
Screenshots
Additional context
Same program with WorkerService debug profile works well.
The text was updated successfully, but these errors were encountered: