【发布时间】:2019-11-10 10:45:24
【问题描述】:
我的 EC2 可以通过配置文件定期访问 S3:
aws s3 ls --profile myprofile s3://
在同一个 EC2 上,我创建了 docker 容器并安装了 aws cli 工具。
创建了与主机 ec2 上内容相同的 ~./aws/config 文件,但来自 docker 容器的此命令现在给出错误:
aws s3 ls --profile myprofile s3://
Error when retrieving credentials from Ec2InstanceMetadata: No credentials found in credential_source referenced in profile myprofile
如何启用对容器内 S3 的访问?
【问题讨论】:
-
尝试以 SYS ENV 的形式提供凭据:
docker run -e AWS_ACCESS_KEY_ID=XXX -e AWS_SECRET_ACCESS_KEY=XXXX IMAGE -
您应该能够正常使用EC2 metadata service 来检索实例的 IAM 角色的凭证。 Docker 本身不会阻止访问神奇的 169.254.169.254 IP 地址。
-
开启
debug时,docker上的MainThread - urllib3.connectionpool - DEBUG - Starting new HTTPS connection (1): sts.amazonaws.com:443出错。
标签: amazon-web-services docker amazon-s3 aws-cli