title: AWS S3 problem with docker using asp net core mvc
body: <p>I am trying to run my microservice app (Asp Net Core) with docker and trying to get it work with Amazon AWS S3 Buckets. I am a totally Noob using Amazon AWS so I read the documentation and made this work but without docker and now I am trying to use it with docker but cannot make this work.</p>
  <p>I have a file called <code>credenciales.txt</code> inside my project folder that stores my amazon credentials like access keys:</p>
  <pre><code>[myprofilename]
  aws_access_key_id=myAccessKey
  aws_secret_access_key=mySecretKey
  </code></pre>
  <p>This is my appsettings.json:</p>
  <pre><code>{
    &quot;Logging&quot;: {
      &quot;LogLevel&quot;: {
        &quot;Default&quot;: &quot;Information&quot;,
        &quot;Microsoft&quot;: &quot;Warning&quot;,
        &quot;Microsoft.Hosting.Lifetime&quot;: &quot;Information&quot;
      }
    },
    &quot;ApiSettings&quot;: {
      &quot;GatewayAddress&quot;: &quot;http://localhost:5000&quot;
    },
    &quot;ElasticConfiguration&quot;: {
      &quot;Uri&quot;: &quot;http://localhost:9200&quot;
    },
  
    &quot;AWS&quot;: {
      &quot;Profile&quot;: &quot;myprofilename&quot;,
      &quot;Region&quot;: &quot;us-east-2&quot;,
      &quot;ProfilesLocation&quot;: &quot;credenciales.txt&quot;
    },
  
    &quot;ConfigKeys&quot;: {
      &quot;AwsBucketName&quot;: &quot;bucketName&quot;,
      &quot;AwsS3BaseUrl&quot;: &quot;amazonaws&quot;,
      &quot;AwsRegion&quot;: &quot;us-east-2&quot;,
      &quot;FileSize&quot;: &quot;2000000&quot;
    },
  
    &quot;AllowedHosts&quot;: &quot;*&quot;
  }
  </code></pre>
  <p>When running the app with <code>dotnet run --urls=https://localhost:7888</code> and tried to upload a file to amazon S3 Bucket it Worked!!!</p>
  <p>but when trying to run it with docker with <code>docker-compose up</code> and attempt to upload a file to amazon S3 it does not work, it is likely because it cannot get the credentials file(I think).</p>
  <p>This is my docker file from the project that I am trying to make aws work:</p>
  <pre><code>FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
  WORKDIR /app
  EXPOSE 80
  EXPOSE 443
  
  FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
  WORKDIR /src
  COPY [&quot;Apps/Web/ASPNET/Sistema/Sistema.csproj&quot;, &quot;Apps/Web/ASPNET/Sistema/&quot;]
  RUN dotnet restore &quot;Apps/Web/ASPNET/Sistema/Sistema.csproj&quot;
  COPY . .
  WORKDIR &quot;/src/Apps/Web/ASPNET/Sistema&quot;
  RUN dotnet build &quot;Sistema.csproj&quot; -c Release -o /app/build
  
  FROM build AS publish
  RUN dotnet publish &quot;Sistema.csproj&quot; -c Release -o /app/publish
  
  FROM base AS final
  WORKDIR /app
  COPY --from=publish /app/publish .
  ENTRYPOINT [&quot;dotnet&quot;, &quot;Sistema.dll&quot;]
  </code></pre>
  <p>docker files from src, docker-compose.yml</p>
  <pre><code>version: '3.4'
  
  services:
      sistema:
          image: ${DOCKER_REGISTRY-}sistema
          build:
              context: .
              dockerfile: Apps/Web/ASPNET/Sistema/Dockerfile
  </code></pre>
  <p><strong>docker-compose.override.yml</strong></p>
  <pre><code>version: '3.4'
  
  services:
  
      inventario.api:
          container_name: inventario.api
          environment:
              - ASPNETCORE_ENVIRONMENT=Development
              - &quot;DatabaseSettings:ConnectionString=Server=myServer;Port=myPort;Database=myDatabase;User Id=myUser;Password=HelloWorld;&quot;
              - &quot;ElasticConfiguration:Uri=http://elasticsearch:9200&quot;
          depends_on:
              - inventariodb
          ports:
              - &quot;5035:80&quot;
  
      ocelotapigw:
          container_name: ocelotapigw
          environment:
              - ASPNETCORE_ENVIRONMENT=Development
              - &quot;ElasticConfiguration:Uri=http://elasticsearch:9200&quot;
          depends_on:
              - inventario.api
          ports:
              - &quot;5000:80&quot;
  
      sistema:
          container_name: sistema
          environment:
              - ASPNETCORE_ENVIRONMENT=Development
              - &quot;ApiSettings:GatewayAddress=http://ocelotapigw&quot;
              - &quot;ElasticConfiguration:Uri=http://elasticsearch:9200&quot;
          depends_on:
              - ocelotapigw
              - inventario.api
          ports:
              - &quot;1235:80&quot;
  </code></pre>
  <p>How do I make this work using docker? Do I have to use Amazon AWS CLI or something like that?</p>
  <p>PD: The app is in development and I am using Ubuntu 20.04 with VS Code. I am planning to deploy the microservice app to amazon EKS later few months.</p>