Reputation: 151
I wanted to know about the disadvantages of docker --squash
in a production environment. The reason why I am using this command is:
I needed dependencies(gcc,make,autoconf, etc) to build my PHP-react project. Also, I have created my own PHP base image which gives me these packages. Now, the problem is I want to uninstall these dependencies once my project is built. I tried adding a RUN apt-get remove gcc make
command at the end of Dockerfile but as this will be a separate layer from where these dependencies were installed, the overall size of the docker image remains the same.
I found about the docker --squash which will merge all layers into 1 layer and I have achieved ~33% space reduction. But the problem is I can't use the docker squash command with docker-compose and also I don't understand if there are any performance issues or other disadvantages of using docker --squash
in production.
I got to know about multi stage build but this is not same as I don't know which files I should not be copying in order to remove those dependencies. And also there will be lot of directories to be copied if I use multi-stage build
Thanks!
Upvotes: 4
Views: 973
Reputation: 895
I think they've provided the pros and the cons in its own document clearly.
Pro:
Con:
The --squash
option is an experimental feature, and should not be considered stable.
Squashing images may actually have a negative impact on performance; when pulling an image consisting of multiple layers, layers can be pulled in parallel, and allows sharing layers between images (saving space).
Alternatively
Upvotes: 3