1

I am very lost on the steps with gcloud verse docker. I have some gradle code that built a docker image and I see it in images like so

(base) Deans-MacBook-Pro:stockstuff-all dean$ docker images
REPOSITORY                         TAG       IMAGE ID       CREATED          SIZE
gcr.io/prod-stock-bot/stockstuff   latest    b041e2925ee5   27 minutes ago   254MB

I am unclear if I need to run docker push or not or if I can go strait to gcloud run deploy so I try a docker push like so

(base) Deans-MacBook-Pro:stockstuff-all dean$ docker push gcr.io/prod-stockstuff-bot/stockstuff
Using default tag: latest
The push refers to repository [gcr.io/prod-stockstuff-bot/stockstuff]
An image does not exist locally with the tag: gcr.io/prod-stockstuff-bot/stockstuff

I have no idea why it says the image doesn't exist locally when I keep listing the image. I move on to just trying gcloud run deploy like so

(base) Deans-MacBook-Pro:stockstuff-all dean$ gcloud run deploy stockstuff --project prod-stock-bot --region us-west1 --image gcr.io/prod-stockstuff-bot/stockstuff --platform managed
Deploying container to Cloud Run service [stockstuff] in project [prod-stock-bot] region [us-west1]
X Deploying... Image 'gcr.io/prod-stockstuff-bot/stockstuff' not found.
  X Creating Revision... Image 'gcr.io/prod-stockstuff-bot/stockstuff' not found.
  . Routing traffic...
Deployment failed
ERROR: (gcloud.run.deploy) Image 'gcr.io/prod-stockstuff-bot/stockstuff' not found.

I am doing this all as a playground project and can't seem to even get a cloud run deploy up and running.

I tried the spring example but that didn't even create a docker image and it failed anyways with

ERROR: (gcloud.run.deploy) Missing required argument [--image]: Requires a container image to deploy (e.g. `gcr.io/cloudrun/hello:latest`) if no build source is provided.
4
  • Do you see the container on the GCR console? console.cloud.google.com/gcr It might be that you just named a container like that URL, and was never pushed to the GCR repository.
    – Pentium10
    Sep 10, 2021 at 5:57
  • I really recommend you don't use the latest tag, btw. It will bite you on the arse one day
    – SiHa
    Sep 10, 2021 at 7:58
  • 1
    Hi @Dean Hiller i don't see this image " gcr.io/prod-stockstuff-bot/stockstuff " when you list images in local system. Tag the image with this name " gcr.io/prod-stock-bot/stockstuff " and re run the gcloud run command.
    – Sri
    Sep 10, 2021 at 8:08
  • thankyou @Sri you nailed it. I kept missing I had a typo!! Sep 10, 2021 at 14:38

4 Answers 4

2

This error occurs when an image is not tagged locally/correctly. Steps you can try on your side.

  • Create image locally with name stockstuff (do not prefix it with gcr and project name while creating).
  • Tag image with gcr repo detail
$ docker tag stockstuff:latest gcr.io/prod-stockstuff-bot/stockstuff:latest
  • Check if your image is available in GCR (must see your image here, before deploying on cloudrun).
$ gcloud container images list --repository gcr.io/prod-stockstuff-bot
  • If you can see your image in list, next you can try to deploy gcloud run with below command (as yours).
gcloud run deploy stockstuff --project prod-stock-bot --region us-west1 --image gcr.io/prod-stockstuff-bot/stockstuff --platform managed
1
  • The issue was a darn typo that took forever to figure out gcr.io/prod-stock-bot/stockstuff vs. gcr.io/prod-stockstuff-bot/stockstuff - fun with typos Sep 10, 2021 at 14:37
2

There are 3 contexts that you need to be aware.

  1. Your local station, with your own docker.
  2. The cloud based Google Container Registry: https://console.cloud.google.com/gcr/
  3. Cloud Run product from GCP

So the steps would be:

  1. Build your container either locally or using Cloud Build

  2. Push the container to the GCR registry, if you built locally

    docker tag busybox gcr.io/my-project/busybox docker push gcr.io/my-project/busybox

  3. Deploy to Cloud Run a container from Google Cloud Repository.

1

I don't see this image gcr.io/prod-stockstuff-bot/stockstuff when you list images in the local system. You can create a new image by tagging that image with this image gcr.io/prod-stock-bot/stockstuff and re-run the gcloud run command.

1

for the context I am using Flask (python)

I solved this by

  1. update gcloud-sdk to the latest version
gcloud components update
  1. add .dockerignore, I'm guessing because of the python cache
Dockerfile
README.md
*.pyc
*.pyo
*.pyd
__pycache__
.pytest_cache
  1. expose the port to env $PORT
CMD exec gunicorn --bind :$PORT --workers 1 --threads 8 --timeout 0 app:app

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.