I build an image from a dockerfile, now I found that its size is 450 MB. But I wanted to reduce the size without deleting it or making changes in dockerfile. How can I do that ?
I didn’t find any solution.
I build an image from a dockerfile, now I found that its size is 450 MB. But I wanted to reduce the size without deleting it or making changes in dockerfile. How can I do that ?
I didn’t find any solution.
2
Answers
No. This is not possible without making changes in the Dockerfile. That would be peculiar, as Docker would already have done that in the first place, when building the image.
Docker already uses layering, which means that the space an image takes up, is the space the total image actually consumes.
So the only thing you can do is find out whether the images your image is based on, are bloated, and then possibly select another one.
slim
variants, which are a little bit stripped down. I don’t know the exact details, but they should be smaller in size.mcr.microsoft.com/azure-cli
; more than 1 GB). The question is whether you need all of the stuff within it.You cannot reduce image size, but you can find ways to get base images with less MB.
For example, always check the alpine images. You can check what is alpine here
For example, a node js image base has a size of about 600MB, while same image in an alpine format has about 60MB.
You can set this kind of things in the FROM tag in the Dockerfile. For example:
FROM node:14.17.6-alpine3.11
Hope it helps.