7

Folder docker/overlay2 was deleted, and now all my containers fall with error stat /var/lib/docker/overlay2/***: no such file or directory Is there any way to fix this without losing all container data?

randomdude
  • 173
  • 2
  • 7

2 Answers2

7

Solution

docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
nathanpeck
  • 4,608
  • 1
  • 20
  • 18
randomdude
  • 173
  • 2
  • 7
  • 1
    Note this wipes all Docker image and container content, ok if that's what you want to do but might not be subtle enough for some use cases. – Terry Brown Aug 29 '22 at 16:39
2

Is there any way to fix this without losing all container data?

No, you've already lost your container data. All you have left now are pointers to where the data used to be. This is why I strongly recommend against deleting files from within this folder unless you plan to completely reset docker to an empty state. At this point, the cleanest thing to do is shutdown the docker engine, delete the rest of the files and directories from /var/lib/docker, and restart. If you have data in named volumes, you may wish to first save that folder.

BMitch
  • 231,797
  • 42
  • 475
  • 450