【发布时间】:2020-09-16 13:06:55
【问题描述】:
情况
使用 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
当前
- 运行文件shell脚本时
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 身份验证
【问题讨论】:
-
你能解释一下“销售脚本”和“终端”是什么意思吗?
-
我刚刚更新了文件shell脚本和一些描述
-
什么时候执行你的shell脚本?
-
它显示根...
-
因此,当您在终端中运行命令时,您使用的用户与您自己不同。这就解释了为什么它不起作用。
标签: amazon-web-services sh amazon-ecr