Why do we need to keep an eye on the docker layers in the dockerfile?

Every docker container starts from the instruction written in the dockerfile.

But writing random keywords in dockerfile itself does not create an effective container.

The primary goal of writing a docker file is to make the docker containers as lightweight as possible.

The first step to make the container lighter is to use the lighter base image.

The other important factor is to minimise the docker layers.

The layer in a dockerfile is the intermediate image created when an image is built.

Each layer represents an instruction in the Dockerfile image.

To minimise the layers try to club the similar keywords together.

Thank You