3

I've read here that I can use the gcloud sdk to create an instance from a container image. Here's how they say to do for nginx.

gcloud alpha compute instances create-from-container nginx-vm \
    --docker-image=gcr.io/google-containers/nginx:latest \
    --port-mappings=80:80:TCP

I'd like to be able to do this with a node image i've made. I can run it locally using docker run -p 49160:8080 -d myusername/node-web-app, but I don't understand where the image is. Is the idea that I can just scp the image to the VM I have running on cloud compute, and then use a snippet like the one above? How can I find this image in order to do that? This question indicates that they are located at /Users/MyUserName/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/Docker.qcow2, The listing there doesn't look very promising:

- .
- ..
- Docker.qcow2
- console-ring
- console-ring.0
- console-ring.1
- console-ring.2
- console-ring.3
- console-ring.4
- console-ring.5
- hypervisor.pid
- lock
- log
- mac.0
- nic1.uuid
- pid
- syslog
- tty -> /dev/ttys000

Is this the correct way to build from a container on Cloud Compute? If so, where are the images from which the app should be built from?

Community
  • 1
  • 1
1252748
  • 14,597
  • 32
  • 109
  • 229

1 Answers1

6

I don't understand where the image is.

It is in your local docker repository (which could be served by a local registry service, but you don't need one here)

Is the idea that I can just scp the image to the VM I have running on cloud compute the "gcloud alpha compute instances create-from-container" command.

Not exactly: the idea is that you can push your local image to a google cloud registry service: see "GCP: Pushing and Pulling Images"

Once the image is pushed, you can use the "gcloud alpha compute instances create-from-container" command.

So you don't need to know exactly where your image is stored locally.
You only need to:

  • Tag your image by running the following Docker command:

      docker tag [IMAGE] [HOSTNAME]/[YOUR-PROJECT-ID]/[IMAGE]
    
  • push the image to Container Registry by running the following command:

      gcloud docker -- push [HOSTNAME]/[YOUR-PROJECT-ID]/[IMAGE]
    
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250