Jakob Jakob -4 years ago 66
Python Question

Docker build produces many unnamed images

So I'm quite new to Docker, hence apologies if this is a bit of a newbie question...

I've just build my first app using Docker (python 3 flask web app) and it works great.
However, something I noticed when I ran

docker images -a
is that even though I ran just one single build command to build one single image
altum-platform
it seems to have created 11 additional images! One of those is labelled
python
so I'm assuming that has something to do with my app specifying python3. However the others are all unlabeled. And they all take up a considerable amount of space which is not ideal!

I thought Docker images were all one big self-contained thing? Why then, have I got 11 additional images that have automatically been created when I ran one build command?

Docker many images

Answer Source

Docker uses a layered file system. When you have a Dockerfile, Docker creates for each instruction (like FROM, RUN or ADD) a new layer to the image (what you see in your screenshot). The advantage of layers is, that they can be reused.

For example, if you have two images, which both run a program on Ubuntu, Docker can reuse the Ubuntu image instead of creating a new one and thus saves disk space. The size shown by docker images -a represents the virtual size and not the real size. So, your altum-platform is 1.43 GB big and not 4x 1.43 GB. For more information look here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download