Reputation: 2793
I built an image a few weeks ago without using a Dockerfile using this tutorial.
Basically, you run a container from an image, edit this container and then save it as your new image, exit, commit and push. At first my image was somewhat acceptable in size but now it grows in ways i don't understand.
For example, if i need to edit my image, I will :
docker run --name mycontainer -it from/currentimage bash
docker commit from/currentimage
docker push from/currentimage
The problem is that changing a line in a file make the image get bigger by ~250MB. What am I doing wrong?
From there, how can I reduce the size of those, from what I think, useless layers? The other answers on SO always use a Dockerfile or reconfigure it. I don't have one in my case.
Thanks
Upvotes: 0
Views: 1259
Reputation: 149
I had the same issue.
Post I found, application was creating a log file (.core in my case) with large space occupied.
Post you are done with the required changes in container and before committing it, always check for high size files with below command
I deleted it and committed the container. Size was under control.
Upvotes: 0
Reputation: 31681
I cannot tell you why your image grows faster than you expect. You can use the export/import mechanism to flatten the layers though, which may reduce the image size:
docker create --name foo from/currentimage
docker export foo | docker import - from/currentimage:flat
docker rm foo
docker inspect from/currentimage:flat
should now show a single layer.
Upvotes: 6