Run Azure CLI 2.0 in a Docker container

You can use Docker to run a standalone Linux container with the Azure CLI 2.0 pre-installed. Docker lets you get started quickly with an environment where you can try out the CLI to decide if it's right for you, or use our image as a base for your own deployment.

Run in a Docker container

Install the CLI using docker run.

docker run -it microsoft/azure-cli

The CLI is installed on the image as the az command in /usr/local/bin. To log in, run the az login command.

az login

To learn more about different login methods, see Log in with Azure CLI 2.0.


If you want to pick up the SSH keys from your user environment, you can use -v ${HOME}:/root to mount $HOME as /root.

docker run -it -v ${HOME}:/root microsoft/azure-cli

Update Docker image

Updating with Docker requires both pulling the new image and re-creating any existing containers. For this reason you should try to avoid using a container that hosts the CLI as a data store.

Update your local image with docker pull.

docker pull microsoft/azure-cli

Uninstall Docker image

If you decide to uninstall the Azure CLI, we're sorry to see you go. Before you uninstall, use the az feedback command to give some information about why you chose to uninstall and how the CLI could be improved. Our goal is to make the Azure CLI bug-free and user-friendly. If you encountered a bug, we'd appreciate it if you file a GitHub issue.

After halting any containers running the CLI image, remove it.

docker rmi microsoft/azure-cli