Reputation: 3863
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.
So how can i upload a Dockerfile?
Upvotes: 0
Views: 616
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
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
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
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.
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
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.
Upvotes: 3
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