Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

426
Visualizações
Docker image corruption? Remove layers?

After a system restart, it looks like the docker images which were existing are corrupted.

I tried the following-

  1. Rebuild a docker inside that machine - this worked. This image is running fine.
  2. I pulled an image which was already existing, it said layers already exist. But this image still seems to be corrupted.

I feel that removing the image will help. When I try removing, it seems to remove only the tag. It is not removing all the layers. How can I do this?

I tried docker rmi. The image got removed.

Now, I try to pull the image again, some of the layers are already existing. I am trying to run the docker, it says oci runtime error ..... file not found.

These images are working on other machines, and was working on this machine till some hours before.

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

  1. Stop docker service
  2. Remove /var/lib/docker
  3. Start docker service
about 4 years ago · Santiago Trujillo Relatório

0

Warn :
Deleting some directories of /var/lib/docker/overlay2 may look appealing, may work but it is also risky. Indeed, it may create additional inconsistency/corrupted layers.
If you do that, please first make a full backup of folders that you want delete.
I did it two times in a production environment. The first time it worked, the second time it provoked a real mess (hard time and stress to fix that).
Since, I never did it again.

To fix issues with image pulling (layer not found or corrupted), here my tricks.

1 - If you may and want to wipe all your images and containers, you could do that.

Stop and remove all containers (running or not) :

docker rm $(docker stop $(docker ps -aq)) 

And in addition, use the system prune command :

docker system prune --volumes --all 

to delete :

  • all stopped containers
  • all networks not used by at least one container
  • all volumes not used by at least one container
  • all images without at least one container associated to them
  • all build cache

To skip the confirmation dialog, add the -f flag.

It should solve corrupted layer issues since you restart from scratch.

2 - If it doesn't work (that is layers are still not found or corrupted), a possible strategy is ensuring that these failing layers are not used any longer during the pull.

To achieve that :

  • If the problem is a parent image layer : I update the base image specified in the Dockerfile to find a base image version which the layer(s) with the issue is not used any longer. Generally I specify a little more recent version, I build/run. If if works, fine. If it still fails, I update the base image version further.
  • If the problem is an image layer created in my Dockerfile steps itself : I specify the --no-cache flag in docker build.
about 4 years ago · Santiago Trujillo Relatório

0

Just use docker images -a options to know all the images with layers.To know particular layers of particular images you can use docker history $image_name

Also there is a option to remove dangling images by which you can delete it.

docker rmi $(docker images -f dangling=true -q)

Dangling images:

Docker images consist of multiple layers. Dangling images are layers that have no relationship to any tagged images. They no longer serve a purpose and consume disk space. They can be located by adding the filter flag, -f with a value of dangling=true to the docker images command. When you're sure you want to delete them, you can add the -q flag, then pass their ID to docker rmi:

Hope this will help you. Thank you!

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda