I’m started using a docker with basic docker image Linux - x86-64 ( latest ). I have pulled this image with the command
docker pull ubuntu
I run this docker using the command
docker run -it ea4c82dcd15a /bin/bash
where “ea4c82dcd15a” is the IMAGE ID for the image.
This allows me to run the image successfully and work with it. But after doing some work in the container and storing some of my small work data into the container, committing the docker makes the docker image size too huge as it sometimes crosses the size in GBs.
I use below command to commit the docker
docker commit -p -a <author> -m <message> <container_id> <label>:<tag>
But as I told you this is creating a docker image including my work data but with a large size of the image.
Can anyone please clear if I’m doing anything wrong in the whole process or there is any other reason for this is happening?
Please help guys!!
Thanks in Advance…
Is that is the reason for getting the increased size of the docker image?
And if yes, then what should I do to control this. Because however, I need to use the above commands as those are must to run such workspaces in the docker container. I also have created one virtual environment in the docker.
And if yes, the installation of packages is making the big size image, then please help me out to do it properly without getting these type of issues.
Thanks for your reply and Support.
Thanks for the response.
Means using apt for installing/updating packages causes the issue?
My docker image became 4GB in size, I’m not even storing much data into it. Should I stop using docker for the work then? or do we have any other solution to solve this?
Because without apt I cannot work in the docker. Can we have any other way to install such packages that will not cause the issue?
Its pretty hard for me to tell you, since i dont know much about flask/your application.
But it was only a guess, maybe try and “cd /” and run “du -h --max-depth=1” and find out what it is that uses space
In General it is better to just define what you want to accomplish within a dockerfile.
When a container starts, all the differences to the image it’s running from will be part of the container runtime and will be included when you do a docker commit.
The increased size can have multiple reasons and is not limited to your flask application.
You can easily check the difference and probably the reason for the inflated image size with the docker diff {container_name}, which shows you exactly the differences.
HI, I also have this issue… I spin up some postgres image, and add some schema to it then save the images using docker commit command.
And surprised with how the images turn to 23GB… when I tried to inspect inside the image using du -chd 1 command… it seems the total only consist of 4.2GB.
The image size is the sum of the size of the layers. When you change files which are on one of the read-only image layers then you actually duplicate the file, save it on the writable container filesystem and change that. It depends on what storage driver you use but this is what usually happens. This is one possible reason I can imagine why the image size is much larger than the container’s filesystem but it could be something else. We cannot say without knowing what you exactly did and based on what image.
An other possible reason is you run a build process inside the container and saved large amount of data under /tmp. If something deletes files from /tmp when the container starts you won’t see that. You could also have /tmp on tmpfs so your container starts with an empty /tmp in memory hiding the data that was there in the image.