Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass AWS IAM Role to a docker-in-docker container

I have an EC2 instance. It has a python snippet to put some data on the s3 bucket. I have attached the S3 full admin role to this EC2 machine and it works fine. Great.

And then I wanted to run the same python script inside Docker

So I installed docker and executed the python script.

And now I get the error message saying it doesn't have access to S3 resources.

So the problem is, docker network and EC2/Host network are different, right?!?

So I googled and found this:

--net host

But how can I set this command and make the docker-in-docker looks like it is in the same network as it's host?

Where should I supposed to put this --net host part?

like image 538
Jananath Banuka Avatar asked Oct 29 '25 09:10

Jananath Banuka


1 Answers

Move your docker application from standalone EC2 to AWS ECS there you can attach IAM role to container which simplifies work for you.

like image 153
Manoj Bhagwat Avatar answered Oct 31 '25 02:10

Manoj Bhagwat