invalid argument "gcr.io//hello-app:v1" for "-t, --tag" flag: invalid reference format

6/25/2019

I'm following this tutorial: https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app for Google Cloud Platform. I'm using the Google Cloud Shell command line. When I got to the step: To build the container image of this application and tag it for uploading, run the following command:

docker build -t gcr.io/${PROJECT_ID}/hello-app:v1 .

I get an error:

invalid argument "gcr.io//hello-app:v1" for "-t, --tag" flag: invalid reference format

Bear in mind I already have 3 instances cluster (created from Kubernetes Engine) and one VM instance created on its own, existing in my VM instances, created from previous tutorials. Not sure if this has anything to do with the error. Thanks in advance.

-- Hazzaldo
google-cloud-platform
google-kubernetes-engine

3 Answers

6/25/2019

Your tutorial link doesn't work (it's a link to a GCP dashboard, not a tutorial), but presumably there was a step where you were supposed to set the PROJECT_ID variable, which you skipped. The error message shows nothing between the two slashes where ${PROJECT_ID} appears in your command.

-- hobbs
Source: StackOverflow

2/24/2020

I also got the same error when running

docker build -t gcr.io/${PROJECT_ID}/hello-app:v1 .

but changing it to (my PROJECT_ID is say deepworld123)

docker build -t gcr.io/deepworld123/hello-app:v1 .

fixed it for me. Even though i did set PROJECT_ID=deepworld123.

-- David Lo
Source: StackOverflow

6/25/2019

You missed setting PROJECT_ID. In the the "Before you begin" section of the tutorial you linked to it has you run

gcloud config set project [PROJECT_ID]

and then in Step 1 you run

export PROJECT_ID="$(gcloud config get-value project -q)"

After those two commands you should have the shell variable set correctly.

-- Robert Bailey
Source: StackOverflow