从内部泊坞窗集装箱抓取AWS实例元数据? [英] Fetching AWS instance metadata from within Docker container?

查看:181
本文介绍了从内部泊坞窗集装箱抓取AWS实例元数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种简单的方法来从一个码头工人容器访问AWS实例元数据?

Is there a straightforward way to access AWS instance metadata from within a Docker container?

例如,试图获取凭据的EC2实例的IAM角色时,这样的工作就实例本身:

For example, when trying to fetch credentials for an IAM role on an EC2 instance, this would work on the instance itself:

http://169.254.169.254/latest/meta-data/iam/security-credentials/my_role

...而不是从上EC2实例泊坞窗容器中运行之内。

...but not from within a Docker container running on that EC2 instance.

推荐答案

应该有一个容器VS主机这样做没有什么区别。该容器可以直接访问EC2元数据。

There should be no difference between doing this in a container vs the host. The container can access EC2 metadata directly.

root@f1e5964e87e4:/# curl http://169.254.169.254/latest/meta-data/iam/security-credentials/myrole
{
  "Code" : "Success",
  "LastUpdated" : "2014-03-14T17:07:24Z",
  "Type" : "AWS-HMAC",
  "AccessKeyId" : "mykey",
  "SecretAccessKey" : "mysecret",
  "Token" : "mytoken",
  "Expiration" : "2014-03-14T23:09:39Z"
}

你看到了什么,当你从容器内用命令?已指派一个IAM角色?

What do you see when you try the command from within the container? has an IAM role assigned?

这篇关于从内部泊坞窗集装箱抓取AWS实例元数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆