18

When you create an instance on google compute engine there is an option to "Deploy a container image to this VM instance", which if you select asks for a container image

In the box for the container image it says "for example, gcr.io/google-containers/busybox" and clicking on the question mark next to the words "Container image" brings up "Name of a public image on any registry, or a private image hosted on Google Container Registry."

From this I infer that I can deploy an image directly from docker hub without needing to first upload it to the google container repository. However, I am having trouble with how I am supposed to direct the instance to the desired image.

For example if the image is username/repo:tag, I have tried putting username/repo or username/repo:tag as the container image, but when I load up the instance I am not in the container and the image isn't even listed on the docker images -a

What address should I be using?

Michoel Snow
  • 363
  • 3
  • 8
  • You have to check whether your Container image is public on dockerhub. The `username/repo:tag` command should be able to link your image to your VM instance. Either way, there are other ways by which you can associate docker images into your VM, you can try those. – Kanishk Kumar Gupta Jun 18 '18 at 07:11

3 Answers3

23

Yes, you may deploy an image directly from the docker hub.

When creating an instance in GCE, in the Container Image text box, you have to type the full path of the docker hub repository.

For instance, for the nginx public docker image, the container image that you should type is registry.hub.docker.com/library/nginx

The registry path for any official docker hub image should be written in the following way: registry.hub.docker.com/library/image.

For a private docker image, the container image that you should type is registry.hub.docker.com/username/repo or registry.hub.docker.com/username/repo:tag.

Mahmoud Sharif
  • 1,085
  • 6
  • 12
  • 3
    Thanks for the help. Can I ask if that information is in documentation somewhere (either google cloud's or docker hub's), and if so where? – Michoel Snow Jun 19 '18 at 13:35
  • I did not find the answer on a public website. I found a similar question on this [post](https://stackoverflow.com/questions/34198392/docker-official-registry-docker-hub-url). Through trial and error, I've tested it. It worked. – Mahmoud Sharif Jun 19 '18 at 20:03
  • 3
    Private dockerhub images require authentication, I don't see how this is possible with the feature to deploy a container to a VM. – Duncan Gravill Dec 31 '18 at 09:14
  • I'm facing the login problem too. Getting ```Error: Failed to start container: Error response from daemon: {"message":"pull access denied for registry.hub.docker.com/tiagogouvea/gtgt-backend-test, repository does not exist or may require 'docker login'"}``` – Tiago Gouvêa May 10 '19 at 17:39
  • The question was about how to deploy a container from Docker hub to GCE. If you have issues with authentication, please submit it in a new question. – Mahmoud Sharif May 19 '19 at 18:24
  • Is it me or this is not working? I tried passing `registry.hub.docker.com/_/node/12.18.0-alpine3.12`, `registry.hub.docker.com/_/node:12.18.0-alpine3.12`, and both with `http://`, without success – Leandro Jun 13 '20 at 19:53
  • 4
    It seems to be not possible anymore. https://cloud.google.com/run/docs/deploying#images – Eran Chetzroni Aug 25 '20 at 13:28
3

docker.io/<username>/<repo>:<tag> works as well. Of course it points to the same registry as registry.hub.docker.com, but the pattern nicely matches gcr.io/<username>/<repo>:<tag>.

Ernesto Elsäßer
  • 912
  • 11
  • 11
0

You can use registry.hub.docker.com/<username>/<image-name>:<tag>

So to deploy to GKE

Paul Hilliar
  • 579
  • 6
  • 8