PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, November 6, 2022

[FIXED] How to fix Docker invalid reference format?

 November 06, 2022     docker     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing