container-registries – skill DevOps & Hạ tầng cho agent AI
Quản lý container registry gồm ECR, ACR, GCR và Docker Hub.
Cài skill container-registries bằng một lệnh
Chọn công cụ bạn đang dùng, copy lệnh và dán vào terminal. Skill sẽ nằm trong thư mục skills của công cụ đó và sẵn sàng dùng ở phiên làm việc tiếp theo.
Claude Code
mkdir -p ~/.claude/skills && curl -fsSL https://skill.dn1nguoi.com/z/container-registries-17076.tgz | tar xz -C ~/.claude/skills
Gọi trong Claude Code: /container-registries – rồi mô tả công việc bạn muốn làm.
Codex
mkdir -p ~/.codex/skills && curl -fsSL https://skill.dn1nguoi.com/z/container-registries-17076.tgz | tar xz -C ~/.codex/skills
Gọi trong Codex: $container-registries – rồi mô tả công việc bạn muốn làm.
Hermes Agent
mkdir -p ~/.hermes/skills && curl -fsSL https://skill.dn1nguoi.com/z/container-registries-17076.tgz | tar xz -C ~/.hermes/skills
Gọi trong Hermes Agent: /container-registries – rồi mô tả công việc bạn muốn làm.
DeepSeek
mkdir -p ~/.deepcode/skills && curl -fsSL https://skill.dn1nguoi.com/z/container-registries-17076.tgz | tar xz -C ~/.deepcode/skills
Gọi trong DeepSeek: /container-registries – rồi mô tả công việc bạn muốn làm.
Nội dung SKILL.md
Nội dung SKILL.md gốc bằng tiếng Anh.
Container Registries
Store, manage, and distribute container images across cloud and self-hosted registries.
When to Use This Skill
Use this skill when:
- Pushing and pulling container images
- Configuring registry authentication
- Setting up image retention policies
- Managing private container registries
- Implementing image scanning and security
Prerequisites
Confirm account/region/repository and image digest before pushing, publishing, granting cross-account access or enabling deletion policies. Preview cleanup candidates and preserve deployment/rollback digests. ACR retention and geo-replication require a supported SKU (the Standard setup above does not enable every later feature). Google cleanup policy files require the current CLI schema; validate the illustrative object before use. The Harbor archive/flags and Docker Content Trust are historical examples, not universal current signing instructions. TLS alone does not authorize registry clients: configure authentication/access controls before network exposure, and do not run both same-name registry examples simultaneously.
- Docker or Podman installed
- Cloud CLI tools (AWS CLI, az, gcloud) for respective registries
- Appropriate IAM permissions
Docker Hub
Authentication
# Login
docker login
# Login with token
echo "$DOCKER_TOKEN" | docker login -u username --password-stdinPush/Pull Images
# Tag image
docker tag myapp:latest username/myapp:latest
# Push
docker push username/myapp:latest
# Pull
docker pull username/myapp:latestAutomated Builds
Configure in Docker Hub UI:
1. Connect GitHub/Bitbucket repository
2. Set build rules (branch → tag mapping)
3. Configure build context and Dockerfile path
Amazon ECR
Setup
# Create repository
aws ecr create-repository \
--repository-name myapp \
--image-scanning-configuration scanOnPush=true \
--encryption-configuration encryptionType=AES256
# Get registry URI
REGISTRY=$(aws ecr describe-repositories \
--repository-names myapp \
--query 'repositories[0].repositoryUri' \
--output text | cut -d'/' -f1)Authentication
# Login (Docker)
aws ecr get-login-password --region us-east-1 | \
docker login --username AWS --password-stdin $REGISTRY
# Login with credential helper
# Add to ~/.docker/config.json:
{
"credHelpers": {
"123456789.dkr.ecr.us-east-1.amazonaws.com": "ecr-login"
}
}Push/Pull
# Tag and push
docker tag myapp:latest $REGISTRY/myapp:latest
docker push $REGISTRY/myapp:latest
# Pull
docker pull $REGISTRY/myapp:latestLifecycle Policy
# Create lifecycle policy
aws ecr put-lifecycle-policy \
--repository-name myapp \
--lifecycle-policy-text '{
"rules": [
{
"rulePriority": 1,
"description": "Keep last 10 images",
"selection": {
"tagStatus": "any",
"countType": "imageCountMoreThan",
"countNumber": 10
},
"action": {
"type": "expire"
}
}
]
}'Repository Policy
# Allow cross-account access
aws ecr set-repository-policy \
--repository-name myapp \
--policy-text '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "CrossAccountPull",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::OTHER_ACCOUNT:root"
},
"Action": [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage"
]
}
]
}'Azure Container Registry (ACR)
Setup
# Create registry
az acr create \
--resource-group mygroup \
--name myregistry \
--sku Standard \
--admin-enabled false
# Get login server
az acr show --name myregistry --query loginServer -o tsvAuthentication
# Login with Azure CLI
az acr login --name myregistry
# Login with service principal
printf '%s' "$SP_PASSWORD" | docker login myregistry.azurecr.io \
-u "$SP_APP_ID" --password-stdin
# Get access token
az acr login --name myregistry --expose-tokenPush/Pull
# Tag and push
docker tag myapp:latest myregistry.azurecr.io/myapp:latest
docker push myregistry.azurecr.io/myapp:latest
# ACR Build (build in cloud)
az acr build \
--registry myregistry \
--image myapp:latest \
--file Dockerfile .Retention Policy
# Enable retention policy
az acr config retention update \
--registry myregistry \
--status enabled \
--days 30 \
--type UntaggedManifestsGeo-Replication
# Enable replication
az acr replication create \
--registry myregistry \
--location westeurope
# List replications
az acr replication list --registry myregistryGoogle Container Registry (GCR) / Artifact Registry
Setup (Artifact Registry)
# Create repository
gcloud artifacts repositories create myrepo \
--repository-format=docker \
--location=us-central1 \
--description="Docker repository"Authentication
# Configure Docker auth
gcloud auth configure-docker us-central1-docker.pkg.dev
# Or use credential helper
gcloud auth print-access-token | \
docker login -u oauth2accesstoken --password-stdin \
https://us-central1-docker.pkg.devPush/Pull
# Tag for Artifact Registry
docker tag myapp:latest \
us-central1-docker.pkg.dev/PROJECT_ID/myrepo/myapp:latest
# Push
docker push us-central1-docker.pkg.dev/PROJECT_ID/myrepo/myapp:latest
# Pull
docker pull us-central1-docker.pkg.dev/PROJECT_ID/myrepo/myapp:latestCleanup Policy
# Create cleanup policy
gcloud artifacts repositories set-cleanup-policies myrepo \
--location=us-central1 \
--policy=policy.json
# policy.json
{
"name": "delete-old",
"action": {"type": "Delete"},
"condition": {
"olderThan": "30d",
"tagState": "untagged"
}
}GitHub Container Registry (GHCR)
Authentication
# Login with PAT
echo "$GITHUB_TOKEN" | docker login ghcr.io -u USERNAME --password-stdinPush/Pull
# Tag
docker tag myapp:latest ghcr.io/OWNER/myapp:latest
# Push
docker push ghcr.io/OWNER/myapp:latest
# Pull
docker pull ghcr.io/OWNER/myapp:latestVisibility Settings
Configure in GitHub:
1. Go to package settings
2. Change visibility (public/private)
3. Manage access for teams/users
Self-Hosted Registry
Deploy with Docker
# Run registry
docker run -d -p 127.0.0.1:5000:5000 \
--name registry \
-v registry-data:/var/lib/registry \
registry:2
# Configure TLS
docker run -d -p 443:5000 \
--name registry \
-v /certs:/certs \
-v registry-data:/var/lib/registry \
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/domain.crt \
-e REGISTRY_HTTP_TLS_KEY=/certs/domain.key \
registry:2Harbor Registry
# Download Harbor
wget https://github.com/goharbor/harbor/releases/download/v2.9.0/harbor-online-installer-v2.9.0.tgz
tar xzvf harbor-online-installer-v2.9.0.tgz
# Configure harbor.yml
# Set hostname, https certificate, admin password
# Install
./install.sh --with-trivy --with-chartmuseumImage Security
Vulnerability Scanning
# ECR - Enable scan on push
aws ecr put-image-scanning-configuration \
--repository-name myapp \
--image-scanning-configuration scanOnPush=true
# Get scan results
aws ecr describe-image-scan-findings \
--repository-name myapp \
--image-id imageTag=latest
# ACR: enable/configure Microsoft Defender for Containers/registries through
# the supported subscription workflow, then inspect findings; there is no
# generic `az acr run-scan` command.Image Signing
# Enable content trust
export DOCKER_CONTENT_TRUST=1
# Sign image on push
docker push myregistry/myapp:latest
# Verify signature
docker trust inspect myregistry/myapp:latestCommon Issues
Issue: Authentication Expired
Problem: Push/pull fails with auth error
Solution: Re-run login command, check credential helper
Issue: Image Not Found
Problem: Pull fails with manifest unknown
Solution: Verify tag exists, check registry URL
Issue: Push Permission Denied
Problem: Cannot push to repository
Solution: Check IAM permissions, verify repository exists
Issue: Rate Limiting (Docker Hub)
Problem: Too many requests error
Solution: Authenticate for higher limits, use pull-through cache
Best Practices
- Enable vulnerability scanning on all repositories
- Implement lifecycle policies to manage storage costs
- Use immutable tags for production images
- Configure cross-region replication for availability
- Use service accounts/principals for CI/CD authentication
- Enable audit logging for compliance
- Implement image signing for supply chain security
- Use pull-through cache to avoid rate limits
Related Skills
- docker-management (
docker-management) - Building images - container-scanning (
container-scanning) - Security scanning - aws-iam (
aws-iam) - AWS permissions
#
… (nội dung đầy đủ có trong gói tải về)
Skill liên quan
- cost-optimization – Chiến lược và mẫu tối ưu chi phí cloud trên AWS, Azure và GCP.
- secrets-management – Triển khai quản lý secrets an toàn cho pipeline CI/CD bằng Vault, AWS Secrets Manager…
- service-mesh-observability – Triển khai khả năng quan sát toàn diện cho service mesh, bao gồm distributed tracing…
- shellcheck-configuration – Nắm vững cấu hình và cách dùng ShellCheck để phân tích tĩnh chất lượng shell script…
- slo-implementation – Định nghĩa và triển khai Service Level Indicators (SLIs) và Service Level Objectives…
- database-cloud-optimization-cost-optimize – Bạn là chuyên gia tối ưu chi phí cloud, chuyên giảm chi phí hạ tầng mà vẫn giữ hiệu năng…
- datadog – Triển khai giám sát Datadog và APM cho hạ tầng và ứng dụng.
- migration-architect – Lập kế hoạch di chuyển không gián đoạn, kiểm tra tương thích và tạo chiến lược rollback…