Search code examples
podmanazure-container-registry

How to login to Azure Container Registry using Podman?


I would like to log in to the Azure Container Registry (ACR) using Podman CLI. I have obtained the admin username and password from Access key menu. I tried to log in using this command:

sudo podman login xyzabc.azurecr.io -u <user> -p <password>

However, I got the following error:

Error: logging into "xyzabc.azurecr.io": invalid username/password


Solution

  • An alternative way to log in to Azure Container Registry is to generate an access token first:

    az acr login --name xyzabc --expose-token
    

    The output will be like as follows:

    {
      "accessToken": "eyJhbGciOiJSUzI1NiIs....",
      "loginServer": "xyzabc.azurecr.io"
    }
    

    To login, copy the access token and use the default username:

    sudo podman login -u 00000000-0000-0000-0000-000000000000 -p <token> xyzabc.azurecr.io
    

    Note: The token expires after 3 hours, therefore you need to regenerate it.

    References: