> ## Documentation Index
> Fetch the complete documentation index at: https://enterprise-docs.dify.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# 容器镜像仓库（插件）

## 支持的容器镜像仓库

* AWS ECR（with AK/SK or IRSA）/ Azure ACR / Aliyun ACR (with AK/SK) / Tencent TCR (with AK/SK) / Dockerhub / Google Artifact Registry

## 为什么需要配置容器镜像仓库

* Dify 企业版需要使用容器镜像仓库来存储和管理插件镜像。
* 插件本身不是一个 Docker 镜像，而是一个包含插件代码和元数据的压缩包。
* 当插件部署到 Kubernetes 集群时，该压缩包会被构建成 Docker 镜像，因此必须配置容器镜像仓库。

## 显示 Helm Chart 值

```bash theme={null}
helm show values dify/dify
```

以下是 Helm Chart 中的容器镜像仓库相关配置示例：

```yaml theme={null}
plugin_connector:
  insecureImageRepo: false
  imageRepoSecret: "image-repo-secret"
  imageRepoPrefix: "docker.io/your-image-repo-prefix"
  imageRepoType: docker
  ecrRegion: "us-east-1"
```

## 如何配置容器镜像仓库

* `imageRepoSecret`（必填）：这是一个 Kubernetes Secret，用于存放访问容器镜像仓库的认证信息。

  * 1.1 **注意**：`imageRepoSecret` 的值必须为 `image-repo-secret`，该 secret 会在部署时创建。

  * 1.2 请将以下脚本保存为 `generate-image-repo-secret.sh`：

    ```bash theme={null}
    #!/bin/bash    

    if [ "$#" -lt 3 ]; then
    echo "How to use: $0 <username> <password> <k8s-namespace> <registry: optional>"
    echo "Example: $0 myuser mypass default https://index.docker.io/v1/"
    exit 1
    fi

    USERNAME="$1"
    PASSWORD="$2"
    NAMESPACE="$3"
    REGISTRY="${4:-https://index.docker.io/v1/}"
    OUTPUT_FILE="./config.json"

    AUTH=$(echo -n "$USERNAME:$PASSWORD" | base64 | tr -d '\n')

    cat > "$OUTPUT_FILE" <<EOF
    {
    "auths": {
        "$REGISTRY": {
        "auth": "$AUTH"
        }
    }
    }
    EOF

    echo "Docker config.json already generate: $OUTPUT_FILE"

    kubectl -n $NAMESPACE create secret generic image-repo-secret --from-file=.dockerconfigjson=$OUTPUT_FILE --from-file=config.json=$OUTPUT_FILE --type=kubernetes.io/dockerconfigjson

    rm "$OUTPUT_FILE"
    ```

  * 1.3 赋予执行权限：

    ```bash theme={null}
    chmod +x ./generate-image-repo-secret.sh
    ```

  * 1.4 执行脚本以创建 Kubernetes Secret：

    ```bash theme={null}
    # ./generate-image-repo-secret.sh <username> <password> <k8s-namespace> <registry: optional>.
    ./generate-image-repo-secret.sh myuser mypass default https://index.docker.io/v1/
    ```
* `imageRepoPrefix`（必填）：你的镜像仓库前缀，用于构建和推送插件镜像。
* `imageRepoType`（必填）：镜像仓库类型：
  * `docker`（默认）：适用于 Docker Hub 或其他兼容 Docker 的仓库
  * `ecr`：适用于 AWS ECR
* `ecrRegion`（可选）：如果使用 AWS ECR，请填写所在区域。
* `insecureImageRepo`（可选）：如果你的镜像仓库不使用 HTTPS，可以设置为 `true`。

## 插件 Pod 的 Kubernetes 调度配置

```yaml theme={null}
plugin_connector:
  nodeSelector: {}
  affinity: {}
  tolerations: []
  labels: {}
```

* 插件 Pod 的调度配置（nodeSelector、affinity、tolerations、labels）继承自 plugin\_connector 服务。

## 如何在网络受限的国家/地区进行配置

如果你的网络无法访问 `docker.io`，可以使用自定义的镜像仓库替代默认镜像地址。

```yaml theme={null}
plugin_connector:
  gatewayImage: "nginx:1.27.3"
  shaderImage: "gcr.io/kaniko-project/executor:latest"
  busyBoxImage: "busybox:latest"
  awsCliImage: "amazon/aws-cli:latest"
  generatorConf: |
    generator:
      repo: langgenius
      python:
        pipMirror: ""
        preCompile: true
        versions:
          python3.13:
            langgenius: docker.io/langgenius/plugin-build-base-python:3.13
          python3.12:
            langgenius: docker.io/langgenius/plugin-build-base-python:3.12
          python3.11:
            langgenius: docker.io/langgenius/plugin-build-base-python:3.11
          python3.10:
            langgenius: docker.io/langgenius/plugin-build-base-python:3.10
```

1. 需要替换为私有镜像的镜像列表：

* `gatewayImage`：插件网关服务镜像。
* `shaderImage`：构建插件时使用的 shader 镜像。
* `busyBoxImage`：插件运行时使用的 busybox 镜像。
* `awsCliImage`：AWS CLI 工具镜像。如果未使用 AWS，可忽略此镜像。
* `python3.xx`：用于构建插件的基础镜像。

2. [将镜像同步到你的私有镜像仓库](/zh/3.2.x/deploy/advanced-configuration/container-registry#syncing-images-to-a-private-registry)
