northtree
northtree

Reputation: 9285

How to specify the container name running on Google Compute Engine?

I am running one container on GCE via

gcloud compute instances create-with-container [INSTANCE_NAME]
--container-image='gcr.io/xxxxx'

https://cloud.google.com/sdk/gcloud/reference/compute/instances/create-with-container

My question is how to specify the container name, which is similar to docker run --name.

Upvotes: 5

Views: 1360

Answers (2)

khuang834
khuang834

Reputation: 971

You do not need to specify the container name when creating the instance.

If your objective is to get to the bash shell of the running container, you can do the following:

  1. ssh to the VM as usual with gcloud compute ssh <instance-name> after it is created with a deployed container.
  2. Find the running container using docker ps, take note of the name of the container
  3. Finally, do docker exec -it <container-name> bash and you'll bring up the bash shell for the running container.

Upvotes: 1

DazWilkin
DazWilkin

Reputation: 40326

It appears to not be possible.

It's a reasonable request.

I recommend you file a feature request on Google's Issue Tracker for Cloud SDK (gcloud) and that you document use-case(s) for needing to query the container by the name there.

Use-cases help justify implementation.

Issue Tracker for Cloud SDK

HTH

Upvotes: 2

Related Questions