0

I have made a Dockerfile to build an image which is based on another Dockerfile. It uses Alpine Linux as a base.

Everything works fine, but when I view the images with the --all switch, I get multiple instances of what appears to be my image and the image for Alpine Linux which it is based on:

$ docker image ls -a
REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
<none>                    <none>              5577c25bccd9        20 hours ago        137MB
<none>                    <none>              48f944e609b5        20 hours ago        137MB
paradroid/myapp           latest              f2a0f99986a6        20 hours ago        137MB
<none>                    <none>              d846706db3f4        20 hours ago        137MB
<none>                    <none>              f1410e1d307e        20 hours ago        137MB
<none>                    <none>              e52e6203864a        20 hours ago        137MB
<none>                    <none>              dd3be52289ce        20 hours ago        5.59MB
<none>                    <none>              8559960a8bd0        20 hours ago        5.59MB
<none>                    <none>              04020d8307b3        20 hours ago        5.59MB
<none>                    <none>              fe0f1e73261c        20 hours ago        5.59MB
<none>                    <none>              12229a67b395        20 hours ago        5.59MB
alpine                    latest              cc0abc535e36        13 days ago         5.59MB

This does not happen when building the Dockerfile which it is based on.

docker system prune does not remove them and any attempt to delete them individually gives this response:

$ docker image rm d846706db3f4
Error response from daemon: conflict: unable to delete d846706db3f4 (cannot be forced) - image has dependent child images

How can I find out what is causing this?

Mickael B.
  • 4,755
  • 4
  • 24
  • 48
paradroid
  • 219
  • 3
  • 12

2 Answers2

5

The <none:none> images are the intermediate layers resulted from your docker build.

Docker image is composed of layers. Each instruction in your Dockerfile results in a layer. These layers are re-used between different images. This results in efficient usage of disk space. So if a is layer being used by another image, you won't be able to delete the layer.

You can run the following command which will remove the layers which are not referenced in any of the images. These layers are called dangling.

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

https://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/

Shashank V
  • 10,007
  • 2
  • 25
  • 41
  • Share your original Dockerfile and other Dockerfile, we can reason about why there are no intermediate layers with your original Dockerfile if that was your question. – Shashank V Jan 07 '20 at 18:11
  • Thanks. Isn't `docker system prune` supposed to remove dangling images? Are these dangling images, as `docker images -f "dangling=true" -q)` doesn't return any response. – paradroid Jan 07 '20 at 18:13
  • `docker system prune` removes all unused containers, networks, images (both dangling and unreferenced). If there are still `:` images after running `docker system prune` , then those are not dangling images. – Shashank V Jan 07 '20 at 18:15
0

use

docker image rm -f imageid

for multiple

docker image rm -f imageid imageid
tgogos
  • 23,218
  • 20
  • 96
  • 128
manojg
  • 36
  • 2
  • I don't think the `--force` is required for multiple deletions and in this case deletion cannot be forced. – paradroid Jan 07 '20 at 18:23