简体   繁体   中英

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. So far I have managed to check wether the VM is running with the following script:

$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. How can I check from a Function App whether Docker is running on the VM using PowerShell?

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 .

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.

Docs on that are here:

https://docs.microsoft.com/en-us/azure/virtual-machines/windows/run-command#powershell

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM