I'm using docker to build images from a docker file. In the process there's some error happened, so the build exit with error code.
When I run docker images
I can see a untagged image. so I tried to remove it docker rmi xxxxx
. But it always fails, it says the images can't be removed because it's used by a stopped container.
So I dig a little deeper. I run docker ps -a
, now I can see a long list of stopped container which are created when the build process fails.
Why there will be container created?? I thought image is like the concept of "class" in programming, and container is instance of the class. Before the image is successfully built, why there'll be instance created? How can I build image without all those stopped containers ?