0

I try to dockerize my Java app. Whenever I build a new image, Docker adds the new image into the list without removing the old images. I don't run the images, I just build again and again. I think it should remove the old ones. Am I wrong?

Docker file

FROM frolvlad/alpine-oraclejdk8:slim
VOLUME /tmp
ADD ./build/libs/admin-app-0.1.jar app.jar
CMD ["java","-jar","app.jar"]

Commands

sudo gradle build
sudo docker build . -t admin-app:latest

The result

enter image description here

Palec
  • 12,743
  • 8
  • 69
  • 138
Erkan Erol
  • 1,334
  • 2
  • 15
  • 32

2 Answers2

1

The reason why you end with dangling images (images not tagged displaying <none> on their name) is that you are building the same image several times successfully with the same name / tag: admin-app:latest.
In this case the previous (old) image that were already built with this tag becomes a "dangling image" since the new built image has replaced it. Docker does not want to overwrite (delete) it and simply indicates that this image has no name by tagging it <none>.

You can also produce dangling images when the build is failing.

To get rid of dangling image you can either:

  • Use a a different tag each time you perform a build to avoid images tagged with <none>.
  • Remove them by using docker rmi $(docker images -f "dangling=true" -q).
Romain
  • 19,910
  • 6
  • 56
  • 65
-1

this is completly normal. docker creates in the build process containers and throw them away after build the final container. see here (http://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/)

youn can easily remove them with some bash rows. see here (How to remove old and unused Docker images)

Community
  • 1
  • 1
Gabbax0r
  • 1,696
  • 3
  • 18
  • 31
  • You can go ahead and remove them without any harm. Remember Docker image is a collection of arranged layers. Whenever you recreate image with some updates, another layer gets added on top of the previously existing layers. Refer this explaination here http://www.projectatomic.io/blog/2015/07/what-are-docker-none-none-images/ – UserASR Jan 17 '17 at 11:47