dockernvidia-docker

Docker build / docker compose up error: Unknown desc = failed to fetch anonymous token: unexpected status: 401 Unauthorized


When building a container (through docker build, docker run or docker-compose) using NVIDIA containers, I get the following error, somewhat randomly. When I usually start building the container, it works the first time. But next few times usually don't work.

------
 > [internal] load metadata for nvcr.io/nvidia/l4t-base:r32.5.0:
------
failed to solve: rpc error: code = Unknown desc = failed to solve with frontend dockerfile.v0: 
  failed to create LLB definition: failed to authorize: 
  rpc error: code = Unknown desc = failed to fetch anonymous token: unexpected status: 401 Unauthorized

My current workaround is to use a slightly different image temporarily whilst I’m adjusting other parts of the Dockerfile.


Solution

  • You have to docker login nvcr.io

    Most of this is documented in the setup docs, unfortunately nvcr.io doesn't have very good SEO or UX, so search results and most attempts don't show this page. This is, confusingly, different to ngc catalog / docker login ngc.nvidia.com.

    [auth] nvidia/tensorrt:pull,push token for nvcr.io
    

    Tips

    Make sure you login to the right container registry. It's in the name of the docker image you are using. e.g. nvcr.io/nvidia/tensorrt:22.01-py3 uses nvcr.io.

    Explanation

    With the benefit of hindsight, I understood failed to fetch anonymous token: unexpected status: 401 Unauthorized. I was not authenticated (or more correctly, I was authenticated to Docker Hub and NGC Catalog instead of nvcr.io). It was giving me an anonymous token, which hit the rate limit. I needed to create an account to get higher limits.