How do I run private docker images on Google Container Engine
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
Running Private Docker Images on Google Kubernetes Engine (GKE)
Deploying applications from private Docker images on GKE requires configuring authentication between your Kubernetes cluster and the container registry where the images are stored. The process varies depending on whether you use Google Artifact Registry (the recommended option), the older Google Container Registry, or a third-party registry like Docker Hub or AWS ECR.
This article walks through each scenario with working configuration examples and troubleshooting guidance.
Prerequisites
Before you begin, ensure you have the following in place:
- An active Google Cloud project with billing enabled.
- The
gcloudCLI installed and authenticated (gcloud auth login). - A running GKE cluster (
gcloud container clusters listto verify). - A private Docker image pushed to your chosen registry.
kubectlconfigured to point at your cluster (gcloud container clusters get-credentials CLUSTER_NAME --zone ZONE).
Option 1: Google Artifact Registry (Recommended)
Google Artifact Registry is the successor to Container Registry and supports Docker, Maven, npm, and other package formats. GKE clusters authenticate to Artifact Registry automatically when the node service account has the correct IAM role.
Grant Access to the Service Account
By default, GKE nodes use the Compute Engine default service account. Grant it the Artifact Registry Reader role:
Push Your Image
Tag and push your Docker image to Artifact Registry:
Deploy to GKE
Create a Kubernetes deployment that references the Artifact Registry image. No image pull secret is needed because the node service account handles authentication:
Option 2: Third-Party Registries (Docker Hub, ECR, etc.)
For images stored outside Google Cloud, you need to create a Kubernetes imagePullSecret that contains the registry credentials.
Create the Secret
For AWS ECR, the server URL has a different format:
Reference the Secret in Your Deployment
Add the imagePullSecrets field to the pod spec:
Attach the Secret to a Service Account
To avoid specifying imagePullSecrets in every deployment, attach the secret to the default service account in the namespace:
After this, all pods in the namespace that use the default service account will automatically use the secret for image pulls.
Option 3: Workload Identity (Production Best Practice)
For production environments, Workload Identity is the recommended way to authenticate GKE workloads to Google Cloud services, including Artifact Registry. It avoids using node-level service accounts, which grant access to all pods on the node.
Then reference serviceAccountName: my-app-sa in your pod spec.
Troubleshooting Image Pull Errors
If pods show ImagePullBackOff or ErrImagePull, use these commands to diagnose:
Common Pitfalls
- Insufficient IAM permissions. The most common cause of image pull failures on Artifact Registry is the node service account missing the
roles/artifactregistry.readerrole. Double-check withgcloud projects get-iam-policy. - Expired credentials for third-party registries. AWS ECR tokens expire after 12 hours. Automate token refresh using a CronJob or an external secrets operator like
external-secrets. - Wrong registry URL. Docker Hub's registry URL is
https://index.docker.io/v1/, notdocker.io. Using the wrong URL in the secret will cause silent authentication failures. - Secret in the wrong namespace. Kubernetes secrets are namespace-scoped. The
imagePullSecretmust exist in the same namespace as the pod that references it. - Using default compute credentials in Autopilot. GKE Autopilot clusters manage node service accounts differently. Use Workload Identity instead of relying on the node service account.
Summary
Running private Docker images on GKE requires properly configured authentication between the cluster and your registry. For Google Artifact Registry, grant the node service account the reader role and no additional secrets are needed. For third-party registries, create a docker-registry secret and reference it in your pod spec or attach it to the namespace service account. In production, use Workload Identity for fine-grained access control. When pods fail to pull images, check IAM permissions, secret configuration, and the registry URL format.
Related reading
- How do I save kubectl logs to a file on my host machine?
- How do I scale up my cluster on Google Container Engine / Kubernetes?
- How do I ssh into the VM for Minikube?
- How do I ssh to nodes in ACS Kubernetes cluster?
- How do I set environment variables during the docker build process?
- How do I set hostname in docker-compose?
- How do I serve index.html in subfolders with S3/Cloudfront?
- How do I set Content-Type when uploading to S3 with AWS CLI?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.