I added two ARG’s in the Dockerfile and the image size went up by 200MB is there a way to prevent this or is there a better alternative?
You could try to run a
docker history YOUR_IMAGE. This tells you which layer of your image consumes how much space.
If your docker installation is quite up to date, you also can build your image with
docker build --squash. This compresses all layers into one.
is the squash flag for a newer version of docker?
introduced with Docker 13 / 17.03.