Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

How to run Azure CLI in a Docker container

Feedback

In this article

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.

Finding available images

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.

Start the Docker container with Azure CLI preinstalled

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.0

Note

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.0

The Azure CLI is available in the image as theaz command, located at/usr/bin/az.

Run the Docker container with a specific version of the Azure CLI

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.0

Update Docker image

To 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:latest

Uninstall Docker image

If 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-cli

Next Steps

Now 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.

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?