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

# 为您的 LangSmith 安装创建镜像

默认情况下，LangSmith 将从我们的公共 Docker 注册表拉取镜像。但是，如果您在无法访问互联网的环境中运行 LangSmith，或者您希望使用私有 Docker 注册表，您可以将镜像镜像到您自己的注册表，然后配置您的 LangSmith 安装以使用这些镜像。

## 要求

* 您的 Kubernetes 集群/机器可以访问的 Docker 注册表的认证访问权限。
* 您的本地机器或可以访问 Docker 注册表的机器上安装了 Docker。
* 您可以在其中运行 LangSmith 的 Kubernetes 集群。

## 镜像镜像

为了方便起见，我们提供了一个脚本来为您镜像镜像。您可以在 [LangSmith Helm Chart 仓库](https://github.com/langchain-ai/helm/blob/main/charts/langsmith/scripts/mirror_langsmith_images.sh) 中找到该脚本。

要使用该脚本，您需要使用以下命令运行脚本，指定您的注册表和平台：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
bash mirror_images.sh <your-registry> [<platform>]
```

其中 `<your-registry>` 是您的 Docker 注册表的 URL（例如 `myregistry.com`），`<platform>` 是您使用的平台（例如 `linux/amd64`、`linux/arm64` 等）。如果您未指定平台，它将默认为 `linux/amd64`。

例如，如果您的注册表是 `myregistry.com`，您的平台是 `linux/arm64`，并且您想使用最新版本的镜像，您将运行：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
bash mirror_langsmith_images.sh --registry myregistry --platform linux/arm64 --version 0.10.66
```

请注意，此脚本将假设您已安装 Docker 并且已对您的注册表进行了身份验证。它还将使用与原始镜像相同的仓库/标签将镜像推送到指定的注册表。

或者，您可以手动拉取、镜像和推送镜像。您需要镜像的镜像可以在 LangSmith Helm Chart 的 `values.yaml` 文件中找到。可以在这里找到：[LangSmith Helm Chart values.yaml](https://github.com/langchain-ai/helm/blob/main/charts/langsmith/values.yaml#L14)

以下是使用 Docker 镜像镜像的示例：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
# 从公共注册表拉取镜像
docker pull langchain/langsmith-backend:latest
docker tag langchain/langsmith-backend:latest <your-registry>/langsmith-backend:latest
docker push <your-registry>/langsmith-backend:latest
```

您需要为要镜像的每个镜像重复此操作。

## 配置

镜像镜像后，您需要配置您的 LangSmith 安装以使用镜像镜像。您可以通过修改 LangSmith Helm Chart 安装的 `values.yaml` 文件来完成此操作。将标签替换为您要使用的版本，例如 `0.10.66`（撰写本文时的最新版本）。

```yaml theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
images:
  imagePullSecrets: [] # 如果需要，在此处添加您的镜像拉取密钥
  registry: "" # 如果您使用我们的脚本将所有镜像镜像到同一个注册表，请将此设置为您的注册表 URL。然后您可以从下面的镜像中删除仓库前缀。
  aceBackendImage:
    repository: "(your-registry)/langchain/langsmith-ace-backend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  backendImage:
    repository: "(your-registry)/langchain/langsmith-backend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  frontendImage:
    repository: "(your-registry)/langchain/langsmith-frontend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  hostBackendImage:
    repository: "(your-registry)/langchain/hosted-langserve-backend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  operatorImage:
    repository: "(your-registry)/langchain/langgraph-operator"
    pullPolicy: IfNotPresent
    tag: "6cc83a8"
  platformBackendImage:
    repository: "(your-registry)/langchain/langsmith-go-backend"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  playgroundImage:
    repository: "(your-registry)/langchain/langsmith-playground"
    pullPolicy: IfNotPresent
    tag: "0.10.66"
  postgresImage:
    repository: "(your-registry)/postgres"
    pullPolicy: IfNotPresent
    tag: "14.7"
  redisImage:
    repository: "(your-registry)/redis"
    pullPolicy: IfNotPresent
    tag: "7"
  clickhouseImage:
    repository: "(your-registry)/clickhouse/clickhouse-server"
    pullPolicy: Always
    tag: "24.8"
```

## Fleet 和 Insights 的附加镜像

如果您使用 Fleet 或 Insights，LangGraph 操作符会为每个部署动态创建 Redis 和 PostgreSQL (pgvector) Pod。这些 Pod 使用操作符模板中定义的镜像，这些模板需要单独配置。

您必须镜像这些附加镜像：

* `docker.io/redis:7`
* `docker.io/pgvector/pgvector:pg15`

然后，在您的 `values.yaml` 中覆盖操作符模板以使用您的镜像镜像：

```yaml theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
operator:
  templates:
    redis: |
      apiVersion: apps/v1
      kind: Deployment
      metadata:
        name: ${service_name}
        namespace: ${namespace}
      spec:
        replicas: 1
        selector:
          matchLabels:
            app: ${service_name}
        template:
          metadata:
            labels:
              app: ${service_name}
          spec:
            enableServiceLinks: false
            containers:
            - name: redis
              image: (your-registry)/redis:7
              ports:
              - containerPort: 6379
                name: redis
              livenessProbe:
                exec:
                  command:
                  - redis-cli
                  - ping
                initialDelaySeconds: 30
                periodSeconds: 10
              readinessProbe:
                tcpSocket:
                  port: 6379
                initialDelaySeconds: 10
                periodSeconds: 5
    db: |
      apiVersion: apps/v1
      kind: StatefulSet
      metadata:
        name: ${service_name}
      spec:
        serviceName: ${service_name}
        selector:
          matchLabels:
            app: ${service_name}
        persistentVolumeClaimRetentionPolicy:
          whenDeleted: Delete
          whenScaled: Retain
        template:
          metadata:
            labels:
              app: ${service_name}
          spec:
            containers:
            - name: postgres
              image: (your-registry)/pgvector/pgvector:pg15
              ports:
              - containerPort: 5432
              command: ["docker-entrypoint.sh"]
              args:
                - postgres
                - -c
                - max_connections=${max_connections}
              env:
              - name: PGDATA
                value: /var/lib/postgresql/data/pgdata
              volumeMounts:
              - name: postgres-data
                mountPath: /var/lib/postgresql/data
            enableServiceLinks: false
        volumeClaimTemplates:
        - metadata:
            name: postgres-data
          spec:
            accessModes: ["ReadWriteOnce"]
            resources:
              requests:
                storage: "${storage_gi}Gi"
```

将 `(your-registry)` 替换为您的注册表 URL。模板变量（`${service_name}`、`${namespace}`、`${max_connections}`、`${storage_gi}`）由操作符在运行时替换，必须保持原样。

配置完成后，您需要更新您的 LangSmith 安装。您可以按照我们的升级指南进行操作：[升级 LangSmith](/langsmith/self-host-upgrades)。如果您的升级成功，您的 LangSmith 实例现在应该使用来自您的 Docker 注册表的镜像镜像。

***

<div className="source-links">
  <Callout icon="terminal-2">
    [将这些文档](/use-these-docs)通过 MCP 连接到 Claude、VSCode 等，以获取实时答案。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/langsmith/self-host-mirroring-images.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
