How to reduce the size of docker image

Let us create a sample docker file for the node.js application

Build a Docker image using the Dockerfile

docker build -t app1 -f dockerfile.nodeapp .

Verify the size of the docker image.

To reduce the size of Docker images, we use multi-stage Docker builds.

Create a multi-stage Dockerfile.

Build a docker image with the new docker file.

docker build -t app1:v2 -f dockerfile.multi .

Verify the size of the docker image.

By Mahesh

Leave a Reply

Your email address will not be published. Required fields are marked *