Azure IotEdge: How to solve 'Docker API responded with status code=InternalServerError'
Sometimes, when working with many modules inside of Azure IotEdge runtime, which might be distributed across different docker repositories, you will most likely get an error, which looks like:
System.AggregateException: One or more errors occurred. (Docker API responded with status code=InternalServerError, image=repository.azurecr.io/singen, tag=. Check container registry (possible authorization failure or container registry down).) ---> Microsoft.Azure.Devices.Edge.Agent.Docker.InternalServerErrorException...
The error shown above can be found in the log of docker module ‘microsoft/azureiotedge-agent’.
This error usually indicates that the authentication to registry is not correctly configured. This authentication is required by the iot edge runtime to pull the module from specified registry. Authentication to registry is done by following command:
iotedgectl login --address registryname.azurecr.io --username user --password ***
The problem with this command is that if you have specified some invalid credentials, command will execute successfully. For example, the mistake, which I usually do is providing the module name in the address of the registry: registryname.azurecr.io/mymodule
This will cause executing of following command
iotedgectl login --address registryname.azurecr.io/mymodule --username
user --password ***
Command will NOT fail, but it will prevent IotEdge Agent to load the module from registry.