You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

推送Docker镜像至Azure容器注册表时出现SubscriptionNotFound错误

解决Azure File卷的SubscriptionNotFound错误

错误根源

你遇到的SubscriptionNotFound错误并非来自Azure容器注册表(ACR)的镜像推送,而是Docker尝试创建/访问Azure File存储卷时无法找到指定订阅,核心问题在于:

  • Azure File卷驱动的配置缺少订阅ID、资源组等关键参数,导致Docker无法定位到目标存储账户所属的订阅
  • Docker使用的Azure凭据未关联到正确的订阅上下文

修复步骤

1. 补全Azure File卷的驱动配置

编辑docker-compose.yaml,在sqldata卷的driver_opts中添加订阅ID和资源组参数,同时移除services中无效的subscription_id环境变量(该变量对卷驱动无作用):

version: '3.8'

services:
  sqlserver:
    container_name: sqlserver
    image: mcr.microsoft.com/mssql/server
    ports:
      - "1433:1433"
    deploy:
        resources:
           reservations:
                cpus: '2'
                memory: 2GB
    environment:
      - ACCEPT_EULA=Y
      - MSSQL_SA_PASSWORD=yourStrongPassword12#
    volumes:
      - sqldata:/var/opt/mssql/server

  web_app:
    container_name: web_app
    build:
        dockerfile: ./Dockerfile
    domainname: <my_name>-library
    ports:
      - "80:80"
    restart: on-failure
    depends_on:
      - sqlserver

volumes:
  sqldata:
      driver: azure_file
      driver_opts:
          share_name: sql-volume
          storage_account_name: kaloyan_123librarystacc
          subscription_id: <你的订阅ID>
          resource_group: <你的资源组名称>

2. 确保Docker与Azure订阅正确关联

执行以下命令验证并设置Azure上下文:

# 登录Azure CLI
az login

# 设置默认订阅为目标订阅
az account set --subscription <你的订阅ID>

# 验证当前订阅信息
az account show

# 登录到你的ACR(如果后续需要推送镜像)
az acr login --name <你的ACR名称>

3. 验证存储账户的有效性

确认存储账户kaloyan_123librarystacc存在于指定的订阅和资源组中:

az storage account show --name kaloyan_123librarystacc --resource-group <你的资源组>

如果命令报错,说明存储账户不存在或资源组/订阅参数错误,需重新创建存储账户或修正配置。

4. 检查权限

确保当前登录的Azure用户拥有以下权限:

  • 目标资源组的Contributor角色
  • 目标存储账户的Storage Account Contributor角色

内容的提问来源于stack exchange,提问作者KaloyankerR

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.19 02:27:06