Authenticating Podman against Azure Container Registry with Azure CLI

Authenticating Podman against Azure Container Registry with Azure CLI

For my development machine I switched from Docker Desktop to podman and Podman Desktop, Podman is basically a drop-in replacement for Docker Desktop but saves me some license fees. I set an alias from docker to podman in my profile file to help my transition to podman.

However, when I tried to authenticate to my Azure Container Registry using the Azure CLI I ran into the following error:

āžœ az acr login -n wesselsregistry
You may want to use 'az acr login -n wesselsregistry --expose-token' to get an access token, which does not require Docker to be installed.
2024-06-19 17:28:43.276039 An error occurred: DOCKER_COMMAND_ERROR
Please verify if Docker client is installed and running.

Azure CLI can't find my docker command, which makes sense as I now use Podman. Azure CLI clearly does not use the alias. However, when you set the DOCKER_COMMAND environment variable, it will use Podman:

$env:DOCKER_COMMAND="podman"

Let's test it, and it works:

āžœ az acr login -n wesselsregistry
Login Succeeded!

To make sure you don't have to do this in every terminal session you can add it to your profile file. I opened my profile file in VS Code by running code $profile and appended the line setting the environment variable there.

WSL2

If you have setup your WSL2 distributions so you can access Podman it works a little different. Your WSL2 distributions will not have the full podman binary but use the podman-remote binary to talk to the shared Podman socket. Your DOCKER_COMMAND environment variable should point to the podman-remote binary. In my case, on Ubuntu, I had to append the following line to by .basrc file to point Azure CLI to Podman instead of Docker.

export DOCKER_COMMAND=podman-remote-static-linux_amd64