This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can trysigning in orchanging directories.
Access to this page requires authorization. You can trychanging directories.
You can use Docker to run a standalone Linux container with Azure CLI preinstalled, providing aquick and isolated environment for using Azure CLI. This container image can also serve as a basefor your own custom deployments.
Warning
Azure CLI 2.63.0 (released August 2024) is the final version supported on the Alpine-based Dockerimage. Microsoft no longer provides updates or bug fixes for this image. To ensure continuedsupport, migrate to the Azure Linux-based image (Azure Linux 3.0), which is fully maintained. Seethe following examples for using Azure Linux 3.0.
To suppress warning messages, run:az config set core.only_show_errors=yes. For details onconfiguration options, seeAzure CLI configuration values and environment variables.
Follow Docker's officialinstructions to install Docker. The release containers derive fromthe official distribution image, install dependencies, and install Azure CLI.
You can find a complete list of Azure CLI Docker images on ourDocker image page.
Important
These images are built from official operating system (OS) images provided by the OS distributor.These images might not have the latest security updates. Microsoft recommends that you update theOS packages to the latest version to ensure the latest security updates are applied.
Open a command prompt and start a Docker container with the Azure CLI preinstalled using thefollowing command. When using this command in a pipeline, use a deterministic tag (such asazurelinux3.0) to ensure consistent behavior.
docker run -it mcr.microsoft.com/azure-cli:azurelinux3.0Note
To use your local SSH keys within the container, mount your .ssh directory by including thefollowing option:--mount type=bind,src="$HOME"/.ssh,dst=/root/.ssh. This option allows thecontainer to access your SSH keys from your user environment.
docker run -it --mount type=bind,src="$HOME"/.ssh,dst=/root/.ssh mcr.microsoft.com/azure-cli:azurelinux3.0The Azure CLI is available in the image as theaz command, located at/usr/bin/az.
You can find available versions in theAzure CLI release notes.
To run a specific version of the Azure CLI in a Docker container, use the following command,replacing2.74.0 with your desired version.
docker run -it mcr.microsoft.com/azure-cli:2.74.0-azurelinux3.0To update the Azure CLI when using Docker, you must pull the latest image and recreate any existingcontainers. Because of this update process, avoid using Azure CLI containers as persistent datastores.
Update your local image using the following command:
docker pull mcr.microsoft.com/azure-cli:latestIf you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use theaz feedback command to let us know what could be improved or fixed. Our goal is to make the AzureCLI bug-free and user-friendly. If you found a bug, we'd appreciate it if youfile a GitHub issue.
To remove the Docker image, first stop any running containers, then run:
docker rmi mcr.microsoft.com/azure-cliNow that you're ready to use the Azure CLI in a Docker container take a quick tour of its keyfeatures and commonly used commands to get started.
Was this page helpful?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?
Was this page helpful?
Want to try using Ask Learn to clarify or guide you through this topic?