0

I am following this tutorial to set up Kubernetes

https://cloud.google.com/kubernetes-engine/docs/tutorials/hello-app

Instead of using the hello project from tutorial, I downloaded an image from my own Docker repository. It is an image of Cassandra

docker pull manuchadha25/codingjedi:3.11.4

The image is available (checked on Google console)

manuchadha25@cloudshell:~ (copper-frame-262317)$ docker images
REPOSITORY               TAG                 IMAGE ID            CREATED             SIZE
manuchadha25/cassandra   3.11.4              ca795bbd8fd7        8 months ago        324MB
manuchadha25@cloudshell:~ (copper-frame-262317)$

I want to now push the image to Container Registry (which I suppose is Google's own registry and is used by Kubernetes to create new nodes with required images). I am getting this error when I try to push the image

manuchadha25@cloudshell:~ (copper-frame-262317)$ docker push gcr.io/${PROJECT_ID}/manuchadha25/cassandra:3.11.4
The push refers to repository [gcr.io/copper-frame-262317/manuchadha25/cassandra]
An image does not exist locally with the tag: gcr.io/copper-frame-262317/manuchadha25/cassandra
manuchadha25@cloudshell:~ (copper-frame-262317)$

What am I doing wrong?

1 Answer 1

2

You need to add a tagged version of your image with the GCR if you want to load an docker image from that GCR.

First read through this: Docker Tags

The thing is the following. If you simply want to run your docker image, you can do just that. There is no need to push your image to the GCR.

By running docker pull manuchadha25/cassandra:3.11.4 you pulled your image from the docker hub. You would be totally fine to just run that. If you really have the need to push your docker image into the GCR of your project you have to tell docker where the GCR "lives".

That is done by tagging an image onto the GCR. A tag for the GCR has three different parts.

| Registry location | Project ID | Image name |

| gcr.io | ${whateveryouridis} | cassandra |

So in your case you would run:

docker tag manuchadha25/cassandra:3.11.4 gcr.io/${whateveryouridis}/cassandra:3.11.4

and than:

docker push gcr.io/${whateveryouridis}/cassandra:3.11.4

But I can't stress this enough

You can do this but it seems that you just want to run your docker image in your GC k8s. Just try docker run manuchadha25/cassandra:3.11.4.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks mate. Don't I need to push the image to GCR if I want to manage a cluster using GCP/Kubernetes. I thought that when I'll run Kubernetes on GCP then due to the integration between the two, Kubernetes will search for the image in gcr.io. I'll be happy to keep the image just in Docker Hub as long as later Kubernetes can find it and use it to create and scale the cluster (is that how it works)?
Youn don't need to push the image to the GCR if your image is available in the public docker hub.
There maybe more of a need to push your image to the GCR if you are working in a closed environment like in a company that creates images that are closed source like. You can even run a mixed environment where you provide your own closed source images to the gcr which in it self need some dependencies (e. g. some DB). Than you can provide the dependency via the official image in the docker hub. The image name just needs to contain the container registry address
I got it. If I am using docker registry, then I specify that kubectl create deployment my-cassandra-app --image=docker.io/manuchadha25/cassandra:3.11.4
Seems right to me. The next step than would be to pack it into a values.yaml file that you can apply via kubectl and change the image location on demand. And for rather sophisticated deployment scenarios automate it via ci / cd and helm or k8s operators. But that is way down the road :)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.