Container Registries¶
Configure OpenShift to pull images from external container registries including private registries.
Introduction¶
Container registries store your Docker/container images. OpenShift can pull from public registries without authentication, but private registries require credentials configured as pull secrets.
Security Best Practice
Use service accounts or tokens with minimal required permissions instead of personal credentials for registry authentication.
Creating Pull Secrets¶
Create authentication credentials for private registries using the OpenShift web console:
- Navigate to Workloads → Secrets
- Click Create → Image pull secret
- Configure the secret:
- Secret name:
my-registry-secret - Authentication type: Image registry credentials
- Registry server address:
registry.example.com - Username: Your registry username
- Password: Your registry password
- Email (optional): Your email address
- Click Create
Using Pull Secrets in Deployments¶
Add pull secrets to your deployments:
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-app
spec:
template:
spec:
imagePullSecrets:
- name: my-registry-secret
containers:
- name: my-app
image: registry.example.com/my-app:latest
Common Registry Examples¶
GitHub Container Registry¶
Create a secret for GitHub Container Registry:
- Navigate to Workloads → Secrets
- Click Create → Image pull secret
- Configure:
- Secret name:
ghcr-secret - Registry server address:
ghcr.io - Username: Your GitHub username
- Password: Your GitHub personal access token
- Click Create
Image Pull Policies¶
Control when OpenShift pulls images:
Pull Policy Options¶
- Always - Always pull the image, even if cached locally
- Use for
latesttags or when images change frequently
- Use for
- IfNotPresent (default) - Pull only if image not already present
- Most efficient for tagged releases
- Never - Only use cached images, never pull
- Use for images you know are already present
Best Practices¶
# Good: Specific version with IfNotPresent
containers:
- name: my-app
image: my-app:v1.2.3
imagePullPolicy: IfNotPresent
# Avoid: latest tag without Always policy
containers:
- name: my-app
image: my-app:latest
imagePullPolicy: Always
Troubleshooting¶
ImagePullBackOff Error¶
Check pod events for details using the OpenShift web console:
- Navigate to Workloads → Pods
- Click on the pod with ImagePullBackOff status
- Review the Events tab for error details
- Check the Logs tab if the pod started
Next Steps¶
Now that you can pull images from registries:
- Deploy Your First Application - Use your private images
- Deploy with GitOps - Automated deployments with private images
- Secrets - Secure handling of registry credentials