Memory issue while building docker image

A dangling image is left behind when a new image of the same name is created, So the dangling images are your previous images every time you create a new one.

To remove them just use:

docker image prune

This will ask you if you are sure (y/n?), and then prune any dangling images. If you don’t want to be asked, then use the -f option to force the prune. Deleting/pruning them manually is the only option.