Azure 容器实例在拉取图像时由于某些问题而失败

Azure container instance failing due some issue while pulling the image

我正在尝试 运行 ACI 上的图像,每当它试图像这样拉图像时 pulling image "mysql@sha256:asakjvnankvaknaklfvkabjaoenla" 容器失败了,而在命令中我给出的图像为 mysql:latest.

az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name xxxxxxx \
    --location eastus \
    --image mysql:latest \
    --dns-name-label xxxxxxxx \
    --environment-variables MYSQL_ROOT_PASSWORD=password@123 \
    --ports 3306 33060 \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME2 \
    --azure-file-volume-mount-path /var/lib/mysql

问题是当它尝试将镜像拉取为 mysql@sha256:asakjvnankvaknaklfvkabjaoenla 时,continer 无法启动,而如果拉取的镜像是拉取镜像“mysql:latest”而不是容器工作.

附上图片以供参考。

不确定为什么会出现此问题

命令 运行 三个容器

ACI_PERS_RESOURCE_GROUP=myresourcegroup
ACI_PERS_STORAGE_ACCOUNT_NAME=mydatabasest2501
ACI_PERS_LOCATION=eastus
ACI_PERS_SHARE_NAME=mysqlshare1
ACI_PERS_SHARE_NAME2=mysqlshare2
ACI_PERS_SHARE_NAME3=mysqlshare3


#I already have storage account so only creating fileshare


# Create the file share
az storage share create \
  --name $ACI_PERS_SHARE_NAME \
  --account-name $ACI_PERS_STORAGE_ACCOUNT_NAME
  

# Create the file share
az storage share create \
  --name $ACI_PERS_SHARE_NAME2 \
  --account-name $ACI_PERS_STORAGE_ACCOUNT_NAME


# Create the file share
az storage share create \
  --name $ACI_PERS_SHARE_NAME3 \
  --account-name $ACI_PERS_STORAGE_ACCOUNT_NAME  
 

 
  
  
  
echo $ACI_PERS_STORAGE_ACCOUNT_NAME

STORAGE_KEY=$(az storage account keys list --resource-group $ACI_PERS_RESOURCE_GROUP --account-name $ACI_PERS_STORAGE_ACCOUNT_NAME --query "[0].value" --output tsv)
echo $STORAGE_KEY  


az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name contaier1 \
    --location eastus \
    --image mysql:latest \
    --dns-name-label uniqueddns1 \
    --environment-variables MYSQL_ROOT_PASSWORD=password@123 \
    --ports 3306 33060 \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME \
    --azure-file-volume-mount-path /var/lib/mysql
    
    

az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name contaier2 \
    --location eastus \
    --image mysql:latest \
    --dns-name-label uniqueddns2 \
    --environment-variables MYSQL_ROOT_PASSWORD=password@123 \
    --ports 3306 33060 \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME2 \
    --azure-file-volume-mount-path /var/lib/mysql


az container create \
    --resource-group $ACI_PERS_RESOURCE_GROUP \
    --name contaier3 \
    --location eastus \
    --image mysql:latest \
    --dns-name-label uniqueddns3 \
    --environment-variables MYSQL_ROOT_PASSWORD=password@123 \
    --ports 3306 33060 \
    --azure-file-volume-account-name $ACI_PERS_STORAGE_ACCOUNT_NAME \
    --azure-file-volume-account-key $STORAGE_KEY \
    --azure-file-volume-share-name $ACI_PERS_SHARE_NAME3 \
    --azure-file-volume-mount-path /var/lib/mysql   
    
    

问题不是您认为的原因,而是将 Azure 文件共享装载到现有文件夹的卷有问题,该文件夹是 MySQL 的依赖项。挂载文件共享时,它会遮挡现有文件夹,然后将无法访问该文件夹中的所有文件。因此 MySQL 将失去依赖性而无法正常工作。查看更多详细信息 here

Mounting an Azure Files share to a container instance is similar to a Docker bind mount. Be aware that if you mount a share into a container directory in which files or directories exist, these files or directories are obscured by the mount and are not accessible while the container runs.

有3种方法可以解决。第一种方式是不挂载File Share,这样就无法持久化数据库的数据。第二种方式是将文件共享挂载到镜像中不存在的新文件夹中,然后将数据复制到新文件夹中。第三种方式是将依赖复制到文件共享中,然后将文件共享挂载到容器中,也可以。

更新:

一个可能的解决办法是,你可以把MySQL镜像推送到一个ACR,然后用它来创建ACI,这样,所有的东西都是一样的,那么可能所有的ACI都成功了,也可能失败了。