简体   繁体   English

通过 Powershell 检查 Docker 容器是否在 Azure VM 上运行

[英]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.

相关问题 通过 powershell 在 Azure vm 上运行命令 - Running Command on Azure vm via powershell 无法登录到在 Azure 上的 Ubuntu VM 上通过 Docker-compose 启动的容器中运行的 SqlServer - Unable to login to SqlServer running in container started via Docker-compose on Ubuntu VM on Azure 通过 powershell 检查 azure VM 计算配额是否可用于 VM 大小 - Check if azure VM compute Quota is available for a VM size via powershell 在 Azure VM 上运行的 Docker 容器中使用 Azure 托管标识 - Using Azure Managed Identity in a Docker container running on an Azure VM 检查Azure VM是否正在运行 - Check if an Azure VM is running 使用Docker在Azure VM上运行Elasticsearch:无法通过本地主机访问 - Running elasticsearch on Azure VM using Docker: cannot access via localhost 通过Powershell在Azure虚拟机上复制并安装exe - Copy and install exe on azure vm via powershell 通过 VM 的 powershell 管理 azure 存储帐户 - Managed azure storage account via powershell for VM 远程客户端无法连接到在 Azure VM 中运行的 redisai docker 容器 - Remote client can't connect to redisai docker container running in an Azure VM 在Azure容器中运行docker命令 - Running docker commands in an Azure container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM