Run Azure CLI in a Docker container

You can use Docker to run a standalone Linux container with the Azure CLI pre-installed. Docker gets you started quickly with an isolated environment to run the CLI in. The image can also be used as a base for your own deployments.

Run in a Docker container

Install the CLI using docker run.

docker run -it microsoft/azure-cli


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

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

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

  1. Run the login command.

    az login

    If the CLI can open your default browser, it will do so and load a sign-in page.

    Otherwise, you need to open a browser page and follow the instructions on the command line to enter an authorization code after navigating to in your browser.

  2. Sign in with your account credentials in the browser.

To learn more about different authentication methods, see Sign in with the 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 let us know what could be improved or fixed. Our goal is to make the Azure CLI bug-free and user-friendly. If you found 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

Next Steps

Now that you're ready to use the Azure CLI, take a short tour of its features and common commands.