Search code examples
linuxazurecontainers

Deploying Docker Image from Azure Container Registry to Web App Container "failed to register layer: Error processing tar file(exit status 1)"


I've tried latest Ubuntu and Python - they successfully extract and mount. However, as soon as I install further dependencies and add my app and push the image to Azure ACR - this error happens.

What is happening on my local machine? I have the Ubuntu image running for example, I install pip3 for example, and "docker commit" the changes locally, then tag the image and push it to ACR. This image will then fail to load with the above error. I can see that the segments in the previous image are already in the registry and only the latest image segment is actually pushed. So the error appears to occur with the latest change to the image.

The full error message is:-

2020-06-25T03:14:43.517Z ERROR - failed to register layer: Error processing tar file(exit status 1): Container ID 197609 cannot be mapped to a host IDErr: 0, Message: failed to register layer: Error processing tar file(exit status 1): Container ID 197609 cannot be mapped to a host ID

2020-06-25T03:14:43.589Z INFO - Pull Image failed, Time taken: 0 Minutes and 46 Seconds

2020-06-25T03:14:43.590Z ERROR - Pulling docker image *******.azurecr.io/seistech-1:v1.0.0.15 failed:

2020-06-25T03:14:43.590Z INFO - Pulling image from Docker hub: .azurecr.io/seistech-1:v1.0.0.15 2020-06-25T03:14:43.987Z ERROR - DockerApiException: Docker API responded with status code=InternalServerError, response={"message":"Get https://.azurecr.io/v2/*******-1/manifests/v1.0.0.15: unauthorized: authentication required, visit https://aka.ms/acr/authorization for more information."}

2020-06-25T03:14:44.020Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)

2020-06-25T03:14:46.491Z INFO - Stopping site *******-dev-container because it failed during startup.

Note re' authentication message(s) - I have created system assigned identity in the web app and assigned image pull permissions in the ACR - so as far as I can tell, there should be no auth issue.

Suggestions appreciated - very little diagnostic info to work with.

Thanks Andy, NZ


Solution

  • For some reason I took several days to find this documentation page

    The key piece of info in the container error log is this:

    ...container id xxxxxx cannot be mapped...
    

    And the shell script to find these items is this:

    $ find / \( -uid 1000000 \)  -ls 2>/dev/null
    

    (where 1000000 is the high ID from the error message)

    The solution then was simple, in the final step of my docker-compose Dockerfile I added:

    && chown -R root:root /home
    

    which is where the find command show all the problematic files were - they were created by a tar -x operation. I haven't dug further into whether this caused the permissions problem.