Use shell script to push docker images (Nodejs app) to 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 script login succeeded
aws configure
Based on the comments.
The reason why the script does not work is that it is executed under root user. The root user does not have aws profile defined, which explain why the script errors out with "You can configure credentials by running "aws configure" message.
To rectify the issue, there are some posibilites: