简体   繁体   中英

'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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM