简体   繁体   English

docker 容器能否访问(非本地)DynamoDB?

[英]Can a docker container get access to (not local) DynamoDB?

I am learning about microservices and Docker and I have made a small application in visual studio 2022 that basically can perform CRUD operations on the DynamoDB (with ASP.NET 6.0).我正在学习微服务和 Docker,我在 Visual Studio 2022 中做了一个小应用程序,它基本上可以在 DynamoDB 上执行 CRUD 操作(使用 ASP.NET 6.0)。 When I run the project on localhost everything works, but as soon as I make a docker container and try to perform crud from the Docker container, I get an error that states:当我在 localhost 上运行项目时,一切正常,但是一旦我制作了 docker 容器并尝试从 Docker 容器中执行 crud,我就会收到一条错误消息:

unable to get iam security credentials from ec2 instance metadata service

I tried a bunch of things like changing my appsettings.json, but came to the conclusion that that is not the problem since it works when I run the solution locally.我尝试了很多方法,例如更改我的 appsettings.json,但得出的结论是这不是问题,因为当我在本地运行解决方案时它可以工作。

When I google about this problem I get overflow with information about running DynamoDB locally.当我用谷歌搜索这个问题时,我得到了关于在本地运行 DynamoDB 的信息。 I get that that is good for developing purpose, but I still want to try to perform CRUD operations on my DynamoDB from the Docker container (and think it must be possible).我知道这有利于开发目的,但我仍然想尝试从 Docker 容器对我的 DynamoDB 执行 CRUD 操作(并且认为它必须是可能的)。

So my question is: is it possible to access my DynamoDB table from a Docker image?所以我的问题是:是否可以从 Docker 图像访问我的 DynamoDB 表?

I have found the answer.我找到了答案。 The problem was in my docker-compose file where I needed the following line: volumes: - ~/.aws/:/root/.aws:ro问题出在我的 docker-compose 文件中,我需要以下行:volumes: - ~/.aws/:/root/.aws:ro

I found it on this post: AWS DotNet SDK Error: Unable to get IAM security credentials from EC2 Instance Metadata Service我在这篇文章中找到了它: AWS DotNet SDK 错误:无法从 EC2 实例元数据服务获取 IAM 安全凭证

by user @smcg由用户@smcg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM