Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'aws configure' in docker container will not use environment variables or config files

So I have a docker container running jenkins and an EC2 registry on AWS. I would like to have jenkins push containers back to the EC2 registry.

To do this, I would like to be able to automate the aws configure and get login steps on container startup. I figured that I would be able to

export AWS_ACCESS_KEY_ID=*
export AWS_SECRET_ACCESS_KEY=*
export AWS_DEFAULT_REGION=us-east-1
export AWS_DEFAULT_OUTPUT=json

Which I expected to cause aws configure to complete automatically, but that did not work. I then tried creating configs as per the AWS docs and repeating the process, which also did not work. I then tried using aws configure set also with no luck.

I'm going bonkers here, what am I doing wrong?

like image 808
nostrebor Avatar asked Jul 15 '16 18:07

nostrebor


1 Answers

No real need to issue aws configure instead as long as you populate env vars

export AWS_ACCESS_KEY_ID=aaaa
export AWS_SECRET_ACCESS_KEY=bbbb
... also export zone and region

then issue

$(aws ecr get-login --region ${AWS_REGION} )

you will achieve the same desired aws login status ... as far as troubleshooting I suggest you remote login into your running container instance using

docker exec -ti CONTAINER  bash

then manually issue above aws related commands interactively to confirm they run OK before putting same into your Dockerfile

like image 177
Scott Stensland Avatar answered Oct 13 '22 10:10

Scott Stensland