DEV Community

Nelson Hernández
Nelson Hernández

Posted on

How to run Azure CLI with Docker

To run the Azure CLI in a Docker container, you can use the following command:

Azure CLI

docker run -it --rm -v ${PWD}:/work -w /work --entrypoint /bin/sh mcr.microsoft.com/azure-cli:latest
Enter fullscreen mode Exit fullscreen mode

Login to Azure

az login
az account list
Enter fullscreen mode Exit fullscreen mode

Output

[
  {
    "cloudName": "AzureCloud",
    "id": "00000000-0000-0000-0000-000000000000",
    "isDefault": true,
    "name": "PAYG Subscription",
    "state": "Enabled",
    "tenantId": "00000000-0000-0000-0000-000000000000",
    "user": {
      "name": "user@example.com",
      "type": "user"
    }
  }
]
Enter fullscreen mode Exit fullscreen mode

Set suscription

az account set --subscription="00000000-0000-0000-0000-000000000000"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)