'Docker failed to register layer

I was trying to pull mysql image with docker pull mysql when my computer got struck. I had to restart my computer, but after restarting and trying to run mysql container with the command docker run -d mysql I am getting the following error:

Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql
5040bd298390: Pull complete 
55370df68315: Pull complete 
fad5195d69cc: Pull complete 
a1034a5fbbfc: Pull complete 
17f3570b42ae: Pull complete 
6bf4b16e5339: Pull complete 
9700c9731729: Pull complete 
f2fea9c5b632: Pull complete 
2f8101f5336d: Extracting    935 B/935 B
0dc8f8a1031a: Download complete 
a1b9627588c7: Download complete 
docker: failed to register layer: rename /var/lib/docker/image/aufs/layerdb/tmp/layer-721305262 /var/lib/docker/image/aufs/layerdb/sha256/06dd4f9415b3f89d3fb1138623cebb7245affc9410611552c6fb52b091587a2e: directory not empty.
See 'docker run --help'.
3b17db599af1654ddb251295a55988121350a88c8176db24ddfe44f9194edb0c

The docker version is 1.12.3

I reckon the aufs is corrupted because of restart, but I dont know how to fix. Please help. Thanks



Solution 1:[1]

Looks like there is a remnant from the past. Delete it:

rm -fr /var/lib/docker/image/aufs/layerdb/sha256/06dd4f9415b3f89d3fb1138623cebb7245affc9410611552c6fb52b091587a2e

Then try:

docker pull mysql

Solution 2:[2]

you need to clean build cache

you can run

docker image prune --all

also you can run

docker system prune --all

be careful last command will remove not used volumes

Solution 3:[3]

I had the same problem with Arch, I guess it happens sometime with a kernel update. Just reboot, and if the problem is the same as me, it might fix ;)

Solution 4:[4]

I had the same exact problem and apparently my Local Disk had ran out of storage. Check that first before clearing up stuff.

Solution 5:[5]

I had the same problem when my computer crashed while running

docker-compose pull

I tried @nehal-j-wani's answer but it failed. I needed to delete all the files that had been created today.

find /var/lib/docker/image/overlay2/layerdb/sha256/* -type f -mtime 0 -exec rm {} \;

I was then able to run the pull command correctly.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Nehal J Wani
Solution 2
Solution 3 idiocrate
Solution 4 Henry Rroga
Solution 5 James Wadsworth