user846445
user846445

Reputation: 179

Passing aws credentials to Docker

I have a docker container golang code which interacts with aws resources. In the testing environment, we use iam role. But How do I test locally. How to use aws credentials to run my docker locally.I am using docker file to build the docker image.

Upvotes: 16

Views: 25515

Answers (1)

Qasim Sarfraz
Qasim Sarfraz

Reputation: 6462

Just mount your credential directory as read-only using:

docker run -v ${HOME}/.aws/credentials:/root/.aws/credentials:ro  ...

given you have root as the user in the container and also have setup the host using this guide for credentials file.

or pass them directly using environment variables as:

docker run -e AWS_ACCESS_KEY_ID=<ACCESS_KEY> -e AWS_SECRET_ACCESS_KEY=<SECRET_KEY> ...

Upvotes: 41

Related Questions