Docker images retention policy

I think it’d be great if there is a setting which sets the number of the latest tags that should be kept on the machine after each image pull. This would prevent keeping a lot of unnecessary images and save disk space.