Question:

A container is running from an image. If we try to delete the image while the container is running, why can't we delete the image?

Answer:

If we attempt to delete the image, Docker will display an error message stating that the image is being used by a container.

The reason is that each line in a Dockerfile creates a layer.