[英]Check if Docker Container is running on Azure VM via Powershell
I am trying to create a PowerShell Script inside a Function App that checks if a Docker Container is running on an Azure VM.我正在尝试在 Function 应用程序中创建一个 PowerShell 脚本,用于检查 Docker 容器是否在 Z3A3F580F142898367 VMFBC7 上运行。 So far I have managed to check wether the VM is running with the following script:
到目前为止,我已经设法使用以下脚本检查 VM 是否正在运行:
$provisioningState = (Get-AzVM -resourcegroupname $rsgName -name $vmName -Status).Statuses[1].Code
$condition = ($provisioningState -eq "PowerState/running")
However, I am not able to check the Docker status.但是,我无法检查 Docker 状态。 How can I check from a Function App whether Docker is running on the VM using PowerShell?
如何从 Function 应用程序检查 Docker 是否正在使用 PowerShell 的 VM 上运行?
Thank you for your help.谢谢您的帮助。
If you're wanting to run the command on the VM to check docker then you could use the Run Command and Invoke-AzVMRunCommand
.如果您想在 VM 上运行命令来检查 docker 那么您可以使用 Run Command 和
Invoke-AzVMRunCommand
。
As this requires the script to be local to where the command is being run you may have to store the script inside the function app or write a wrapper function/module to make use of it.由于这要求脚本位于运行命令的本地,因此您可能必须将脚本存储在 function 应用程序中或编写包装函数/模块以使用它。
Docs on that are here:相关文档在这里:
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/run-command#powershell https://docs.microsoft.com/en-us/azure/virtual-machines/windows/run-command#powershell
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.