Hazzaldo
Hazzaldo

Reputation: 563

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

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.

Upvotes: 5

Views: 11257

Answers (4)

mduca
mduca

Reputation: 15

Had a very similar issue involving PROJECT_ID not being set correctly. The solution has to deal with formating as the error message says.

My PROJECT_ID string has the following format companyname.com:companyname-1 After I followed all the steps in the accepted answer the error message was the same.

It turns out the : needs to be replaced by a /. The final gcr.io string looks like:

gcr.io/companyname.com/companyname-1/hello-app:v1

Upvotes: 0

DLO
DLO

Reputation: 1194

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.

Upvotes: 5

Robert Bailey
Robert Bailey

Reputation: 18230

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.

Upvotes: 8

hobbs
hobbs

Reputation: 240521

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.

Upvotes: 1

Related Questions