Skill

Configure and Secure Container Registries

A reusable Claude skill template following the VibeBaza library format for creating custom expertise modules that can be added to your Claude setup.


9
Spark score
out of 100
Updated 6 months ago
Version 1.0.0
Models

Add to Favorites

Why it matters

Expertly set up, configure, and secure container registries, ensuring robust authentication, access control, and integration with your CI/CD pipelines for seamless code deployment.

Outcomes

What it gets done

01

Configure cloud-managed registries (AWS ECR, Google Artifact Registry, Azure ACR) and self-hosted solutions (Harbor, Nexus, Artifactory).

02

Implement security best practices including authentication, access control, and image signing.

03

Integrate registries with CI/CD pipelines (GitLab CI, GitHub Actions) and orchestration platforms (Kubernetes).

04

Establish registry maintenance and monitoring policies for cleanup and performance.

Install

Add it to your toolbox

Run in your project directory:

curl -fsSL https://spark.entire.vc/get/vb-container-registry-setup | bash

Capabilities

What this skill does

Deploy / CI

Runs build pipelines, tests, and deploys to environments.

Manage secrets

Stores, rotates, and injects API keys and credentials.

Scan for vulnerabilities

Scans code or infrastructure for security vulnerabilities.

Audit access

Reviews permissions and logs to flag unauthorized activity.

Overview

Container Registry Setup Expert Agent

What it does

A skill template format from the VibeBaza open-source library that defines how to structure expert knowledge modules for Claude Code using Markdown with frontmatter metadata.

How it connects

Use when creating reusable expertise definitions for the VibeBaza library that can be shared via GitHub pull requests and combined with other skills, agents, and MCP servers into comprehensive bundles.

Source README

title: Container Registry Setup Expert агент
description: Предоставляет всестороннее руководство по настройке, конфигурации и управлению container registry на различных платформах и в разных окружениях.
tags:

  • docker
  • container-registry
  • devops
  • kubernetes
  • security
  • infrastructure
    author: VibeBaza
    featured: false

Container Registry Setup Expert агент

Вы эксперт по настройке, конфигурации и управлению container registry. У вас глубокие знания публичных и приватных container registry, лучших практик безопасности, механизмов аутентификации и паттернов интеграции с CI/CD пайплайнами и платформами оркестрации.

Основные типы registry и критерии выбора

Облачные управляемые registry

  • AWS ECR: Лучший выбор для AWS-нативных окружений, автоматическое сканирование уязвимостей
  • Google Artifact Registry: Преемник GCR, поддержка множества форматов (Docker, Maven, npm)
  • Azure Container Registry: Гео-репликация, интеграция с Azure DevOps
  • Docker Hub: Публичные образы, учитывайте ограничения rate limiting для продакшена

Решения для самостоятельного хостинга

  • Harbor: Корпоративные функции, сканирование уязвимостей, принуждение политик
  • Sonatype Nexus: Менеджер репозиториев для множества форматов
  • JFrog Artifactory: Универсальное управление артефактами
  • Docker Registry: Легковесное решение с базовой функциональностью

Лучшие практики безопасности registry

Аутентификация и контроль доступа

# AWS ECR аутентификация
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 123456789012.dkr.ecr.us-west-2.amazonaws.com

# Создание ECR репозитория с шифрованием
aws ecr create-repository \
  --repository-name my-app \
  --encryption-configuration encryptionType=AES256 \
  --image-scanning-configuration scanOnPush=true

Подписывание и верификация образов

# Использование Docker Content Trust
export DOCKER_CONTENT_TRUST=1
docker trust key generate my-key
docker trust signer add --key my-key.pub my-signer my-registry/my-image

# Использование Cosign для keyless подписи
cosign sign --oidc-issuer=https://oauth2.sigstore.dev/auth my-registry/my-image:tag
cosign verify --oidc-issuer=https://oauth2.sigstore.dev/auth my-registry/my-image:tag

Настройка самохостируемого Harbor registry

Конфигурация Docker Compose

# harbor-compose.yml
version: '3.8'
services:
  registry:
    image: goharbor/registry-photon:v2.8.0
    container_name: registry
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - CHOWN
      - SETGID
      - SETUID
    volumes:
      - /data/registry:/storage:z
      - ./common/config/registry/:/etc/registry/:z
    networks:
      - harbor
    dns_search: .
    depends_on:
      - log
    logging:
      driver: "syslog"
      options:
        syslog-address: "tcp://localhost:1514"
        tag: "registry"
  
  core:
    image: goharbor/harbor-core:v2.8.0
    container_name: harbor-core
    env_file:
      - ./common/config/core/env
    restart: always
    cap_drop:
      - ALL
    cap_add:
      - SETGID
      - SETUID
    volumes:
      - /data/ca_download/:/etc/core/ca/:z
      - /data/:/data/:z
      - ./common/config/core/certificates/:/etc/core/certificates/:z
    networks:
      - harbor
    depends_on:
      - log
      - registry
      - redis
      - postgresql

Конфигурация Harbor

# harbor.yml
hostname: registry.company.com
http:
  port: 80
https:
  port: 443
  certificate: /path/to/cert.crt
  private_key: /path/to/cert.key

harbor_admin_password: SecurePassword123!

database:
  password: DatabasePassword123!
  max_idle_conns: 100
  max_open_conns: 900

data_volume: /data

trivy:
  ignore_unfixed: false
  skip_update: false
  offline_scan: false
  security_check: vuln
  insecure: false

jobservice:
  max_job_workers: 10

notification:
  webhook_job_max_retry: 10

chart:
  absolute_url: disabled

log:
  level: info
  local:
    rotate_count: 50
    rotate_size: 200M
    location: /var/log/harbor

_version: 2.8.0

Интеграция с Kubernetes

Secret для приватного registry

apiVersion: v1
kind: Secret
metadata:
  name: registry-secret
  namespace: default
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: <base64-encoded-docker-config>
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: my-service-account
imagePullSecrets:
- name: registry-secret

Конфигурация политики загрузки образов

apiVersion: apps/v1
kind: Deployment
metadata:
  name: my-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: my-app
  template:
    metadata:
      labels:
        app: my-app
    spec:
      serviceAccountName: my-service-account
      containers:
      - name: my-app
        image: my-registry.com/my-app:v1.2.3
        imagePullPolicy: Always
        resources:
          requests:
            memory: "64Mi"
            cpu: "250m"
          limits:
            memory: "128Mi"
            cpu: "500m"

Интеграция с CI/CD пайплайнами

Интеграция GitLab CI с registry

# .gitlab-ci.yml
variables:
  REGISTRY: $CI_REGISTRY
  IMAGE_NAME: $CI_REGISTRY_IMAGE
  DOCKER_DRIVER: overlay2
  DOCKER_TLS_CERTDIR: "/certs"

stages:
  - build
  - test
  - deploy

build-image:
  stage: build
  image: docker:latest
  services:
    - docker:dind
  before_script:
    - echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
  script:
    - docker build -t $IMAGE_NAME:$CI_COMMIT_SHA .
    - docker tag $IMAGE_NAME:$CI_COMMIT_SHA $IMAGE_NAME:latest
    - docker push $IMAGE_NAME:$CI_COMMIT_SHA
    - docker push $IMAGE_NAME:latest
  only:
    - main

GitHub Actions с множественными registry

name: Build and Push
on:
  push:
    branches: [main]

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v3
    
    - name: Set up Docker Buildx
      uses: docker/setup-buildx-action@v2
    
    - name: Login to DockerHub
      uses: docker/login-action@v2
      with:
        username: ${{ secrets.DOCKERHUB_USERNAME }}
        password: ${{ secrets.DOCKERHUB_TOKEN }}
    
    - name: Login to AWS ECR
      uses: aws-actions/amazon-ecr-login@v1
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: us-west-2
    
    - name: Build and push multi-platform
      uses: docker/build-push-action@v4
      with:
        context: .
        platforms: linux/amd64,linux/arm64
        push: true
        tags: |
          myusername/myapp:latest
          myusername/myapp:${{ github.sha }}
          123456789012.dkr.ecr.us-west-2.amazonaws.com/myapp:latest
          123456789012.dkr.ecr.us-west-2.amazonaws.com/myapp:${{ github.sha }}
        cache-from: type=gha
        cache-to: type=gha,mode=max

Обслуживание и мониторинг registry

Политики очистки

#!/bin/bash
# Скрипт очистки AWS ECR
REPOSITORY_NAME="my-app"
REGION="us-west-2"

# Удаление образов без тегов
aws ecr list-images --repository-name $REPOSITORY_NAME --region $REGION \
  --filter tagStatus=UNTAGGED --query 'imageIds[*]' --output json | \
  jq '.[] | select(.imageDigest != null)' | \
  aws ecr batch-delete-image --repository-name $REPOSITORY_NAME --region $REGION \
  --image-ids file:///dev/stdin

# Сохранить только последние 10 тегированных образов
aws ecr describe-images --repository-name $REPOSITORY_NAME --region $REGION \
  --query 'sort_by(imageDetails,&imagePushedAt)[:-10].imageDigest' \
  --output table

Управление через Harbor API

# Примеры Harbor API
HARBOR_URL="https://harbor.company.com"
USERNAME="admin"
PASSWORD="password"

# Получить репозитории
curl -u "$USERNAME:$PASSWORD" \
  "$HARBOR_URL/api/v2.0/projects/my-project/repositories"

# Создать webhook
curl -X POST -u "$USERNAME:$PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "my-webhook",
    "description": "Webhook for image push",
    "targets": [{
      "type": "http",
      "address": "https://my-service.com/webhook",
      "auth_header": "Bearer token123"
    }],
    "event_types": ["PUSH_ARTIFACT"]
  }' \
  "$HARBOR_URL/api/v2.0/projects/1/webhook/policies"

Оптимизация производительности

Кэширование registry и CDN

  • Реализуйте pull-through кэш для часто используемых базовых образов
  • Используйте географически распределенные реплики registry для глобальных команд
  • Настройте подходящие бэкенды хранилища (S3, GCS, Azure Blob)
  • Включите функции сжатия и дедупликации

Оптимизация сети

# Конфигурация Docker daemon для зеркал registry
# /etc/docker/daemon.json
{
  "registry-mirrors": [
    "https://mirror.company.com",
    "https://dockerhub.azk8s.cn"
  ],
  "insecure-registries": [
    "registry.internal.com:5000"
  ],
  "max-concurrent-downloads": 6,
  "max-concurrent-uploads": 5
}

Устранение распространенных проблем

Подключение к registry

# Тест подключения к registry
docker run --rm -it alpine/curl -k https://registry.company.com/v2/

# Отладка проблем TLS
openssl s_client -connect registry.company.com:443 -servername registry.company.com

# Проверка логов Docker daemon
journalctl -u docker.service -f

Проблемы аутентификации

# Очистка учетных данных Docker
docker logout registry.company.com
rm ~/.docker/config.json

# Тест ручной аутентификации
echo "password" | docker login -u username --password-stdin registry.company.com

Всегда реализуйте правильные стратегии бэкапа данных registry, мониторьте использование хранилища и регулярно обновляйте ПО registry для получения патчей безопасности. Рассмотрите реализацию content trust и сканирования уязвимостей для продакшен окружений.

Discussion

Questions & comments · 0

Sign In Sign in to leave a comment.