Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.1k views
Welcome To Ask or Share your Answers For Others

1 Answer

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"
}

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...