问题描述
情况
使用Shell脚本将Docker映像(Nodejs应用)推送到ECR
命令
aws ecr get-login-password --region ap-southeast-1 | docker login --username AWS --password-stdin xxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com
文件外壳脚本
#!/bin/sh
docker build -t abc/abc-api ../../abc/abc-api
docker build -t abc/abc-fe ../../abc/abc-fe
aws ecr get-login-password --region ap-southeast-1 | docker login --username AWS --password-stdin xxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com
docker tag abc/abc-api xxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com/abc:api-latest
docker push xxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com/abc:api-latest
docker tag abc/abc-fe xxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com/abc:fe-latest
docker push xxxxxxxxxxx.dkr.ecr.ap-southeast-1.amazonaws.com/abc:fe-latest
当前
- 运行文件外壳脚本时
Unable to locate credentials. You can configure credentials by running "aws configure".
Error: Cannot perform an interactive login from a non TTY device
- 在终端上运行命令时
WARNING! Your password will be stored unencrypted in /home/***/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
我想要什么
Shell脚本登录成功
环境
- Linux mint 20
- aws-cli 2.0.46
- 通过
aws configure
配置的AWS身份验证
解决方法
基于评论。
该脚本不起作用的原因是,该脚本是
要纠正此问题,有一些建议:
- 不要在root用户下运行脚本。以自己的用户身份运行它,因为您已经为自己配置了AWS配置文件(首选)。
- 为root用户创建新的aws配置文件。