My docker image size is 17 GB. I ran the image and deleted a folder of 4GB inside docker container. After committing the container the new image created was also 17 GB . How is it possible?
My docker image size is 17 GB. I ran the image and deleted a folder of 4GB inside docker container. After committing the container the new image created was also 17 GB . How is it possible?
As you add another layer by committing this will result in an additional layer which deletes the files of of a previous layers. If you run an image all layers will be executed and interpreted.
Docker: About images, containers, and storage drivers
docker build --squash can help you to reduce the image size as it merges all layers into one, but it is experimental.
Found the logic: The problem is once i commit a CONTAINER of size say 17 GB and exit it a new image with size 17 GB is created. Even if run the image again and delete files inside them and recommit it, the size wont change. The point is before committing a container we must delete all the unnecessary files and commit the container