Issue
When you run your application without docker, .NET SDK for AWS loads the credentials from the credential file located at C:\Users\.aws\credentials
location.
When running the application in docker, credential file is not found in the container. Hence, SDK fallbacks to other ways to locate the AWS credentials.
Here, I have explained how does AWS SDK for .NET loads credentials.
Solution
Now, answering you question:
- If you are running the docker containers inside ECS, then you can use ECS Task Role, this way you don't need to maintain environment variables.
- If you are not running the docker containers inside ECS, then maintain the following environment variables in your container.
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
This should fix your issue.
Add Environment Variables when running from Visual Studio
In launchSettings.json
, the settings in the Docker section are related to how Visual Studio handles containerized apps.
You can add the above environment variables in the environmentVariables
section as shown below in the picture.

Refer Container Tools launch settings for more detail.