ya man
ya man

Reputation: 547

Docker image layer always already exists

I've got this very weird issue where a layer of a docker image always Already exists, even if I remove /var/lib/docker and pull the image again.

The image in question is a simple nginx server containing an Angular webapp. The "already existing" layer is the one containing the webapp. Which means I can't update it at the moment.

FROM nginx:alpine

COPY nginx.conf /etc/nginx/nginx.conf

WORKDIR /usr/share/nginx/html
COPY dist/ .

I've build the image on my local machine and pushed it to the gitlab container registry. I've checked if the image is fine by pulling the image back from the registry. So the issue is clearly with my server.

The server is an ubuntu machine running Docker version 19.03.8, build afacb8b.

How can the layer still exist if I delete /var/lib/docker?

I got stucked at this point ... Any help is highly appreciated.


Update

I think I should extend my question a bit: I've tried all sorts of combinations of removing docker images:

Like I said above even removing the whole /var/lib/docker directory (while docker service was stopped) didn't solve the issue. In my understanding this is the hard way of removing everything - so to say the brutal way of doing the steps above. But maybe I'm missing something here!?

Before pulling the image after all above measures again, docker images ls -a didn't list any image.

So why is there a single layer left?

cbdbe7a5bc2a: Already exists
10c113fb0c77: Pull complete
9ba64393807b: Pull complete
262f9908119d: Pull complete

Upvotes: 3

Views: 6696

Answers (1)

Naor Tedgi
Naor Tedgi

Reputation: 5717

to clean all images

docker rmi $(docker images -a --filter=dangling=true -q)

to clean ps

docker rm $(docker ps --filter=status=exited --filter=status=created -q)

after running this 2 commands, everything will be deleted

Upvotes: 1

Related Questions