dockergoogle-cloud-platformgoogle-cloud-rungoogle-container-registry

How to pull Docker Hub image to Google Cloud Run?


I'm trying to pull Docker images into Google Cloud Run. I see that I would probably need to pull it first to Google Container registry, but can I somehow avoid it? Also, I'd rather have it straight from the source to have it up-to-date.

enter image description here


Solution

  • I got a look on the project and finally I successfully run it on Cloud Run

    Firstly, you can't pull image outside Google Container Registry or Artifact Registry. So you need to pull the image, tag it and push it in GCP (your project or not, but on GCP)

    Here the steps

    # Pull the image (I did it on Cloud Shell)
    docker pull thecodingmachine/gotenberg:6
    
    # Tag the image
    docker tag thecodingmachine/gotenberg:6 gcr.io/<MY_PROJECT_ID>/thecodingmachine/gotenberg:6
    
    #Push the image (no authentication issue on Cloud Shell)
    docker push gcr.io/<MY_PROJECT_ID>/thecodingmachine/gotenberg:6
    
    # Deploy on Cloud Run
    gcloud run deploy --image=gcr.io/<MY_PROJECT_ID>/thecodingmachine/gotenberg:6 \
      --port=3000 --region=us-central1 --allow-unauthenticated --platform=managed \
      --command=gotenberg gotenberg
    

    The trick on the Cloud Run deployment is:

    So then, use the Cloud Run URL instead of the http://localhost:3000 that you have in the documentation and enjoy!