user1584421
user1584421

Reputation: 3863

Upload Dockerfile to Google Cloud Services

I just made a Google Cloud account, and i want to deploy my containerized flask application.

I reached the early instance creation phase, and i selected Deploy a Container. However, there is no option to upload my Dockerfile.

There is only a dropdown.

enter image description here

So how can i upload a Dockerfile?

Upvotes: 0

Views: 616

Answers (2)

Jose Luis Delgadillo
Jose Luis Delgadillo

Reputation: 2468

You can’t upload your image directly in that way, you need to upload it first to your Container Registry.
To push any local image to Container Registry using Docker or another third-party tool, you need to first tag it with the registry name and then push the image.

Tag the local image with the registry name

  • To tag an image:

Verify that you have configured authentication to Container Registry.

  • Choose a hostname, which specifies location where you will store the image. (gcr.io hosts images in data centers in the United States, but the location may change in the future)

  • Choose an image name, which can be different from the image's name on your local machine.

  • Combine the hostname, your Google Cloud Console project ID, and image name:

HOSTNAME/PROJECT-ID/IMAGE
  • Tag the local image with the registry name by using the command:
docker tag SOURCE_IMAGE HOSTNAME/PROJECT-ID/IMAGE

where SOURCE_IMAGE is the local image name or image ID.

Push the tagged image to Container Registry

  • Push the tagged image to Container Registry by using the command:
docker push HOSTNAME/PROJECT-ID/IMAGE

This command pushes the image that has the tag latest.

When you push an image to a registry that does not exist yet in your project, Container Registry creates a storage bucket.

  • To view the image you pushed:

Go to the Cloud Console to view the registry and image.

Run gcloud container images list-tags to view the image tag and the automatically-generated digest:

gcloud container images list-tags HOSTNAME/PROJECT-ID/IMAGE

The command's output is similar to the following:

DIGEST        TAGS        TIMESTAMP
44bde...      test        2017-..-..

I have reproduce it in my own project and I was able to create the VM instance using my own image.

When you have done the steps above you will be able to see your image in your Container Registry. And if you click the name of the image you will see something like enter image description here

Then you can use this URL gcr.io/>>MY-TEST-PROJECT<</myapp28032021 with the full repository name to create your instance.

Additionally, if you click the name of the image you will be able to Deploy it directly to Cloud Run, GCE and GKE. enter image description here

Upvotes: 3

Sri
Sri

Reputation: 318

For that you need to have an image in GCR(Google Container Registry). This link will help to pull and push images from GCR.

https://cloud.google.com/container-registry/docs/pushing-and-pulling

Upvotes: 1

Related Questions