Issue
I am trying to run docker inside a shell script. This is what my script looks like :-
#!/bin/bash
aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin <account-id>.dkr.ecr.us-east-1.amazonaws.com
IMAGE=$(aws ecr describe-images --repository-name repo --query 'sort_by(imageDetails,& imagePushedAt)[-1].imageTags[0]')
echo $IMAGE
docker pull https://<account-id>.dkr.ecr.us-east-1.amazonaws.com/repo:$IMAGE
docker run -d -p 8080:8080 https://<account-id>.dkr.ecr.us-east-1.amazonaws.com/repo:$IMAGE
But when i run the script, i keep running into
docker: invalid reference format.
See 'docker run --help'.
and i'm not sure what i'm doing wrong. Any help will be appreciated.
Solution
From the docs:
The image name format should be registry/repository[:tag] to pull by tag, or registry/repository[@digest] to pull by digest.
so for the pull command you should use:
$ docker pull <account-id>.dkr.ecr.us-east-1.amazonaws.com/repo:$IMAGE
then for the run command, you should use:
$ docker run -d -p 8080:8080 <account-id>.dkr.ecr.us-east-1.amazonaws.com/repo:$IMAGE
Answered By - Paolo Answer Checked By - Marie Seifert (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.