In the azure build pipeline, how to cleanup the docker image from self hosted agent once it is pushed?

I am using self hosted agent to run my build pipeline. The pipeline builds and pushes the docker image using the 1st task as shown in the following screenshot.

docker tasks

Once the image is built and pushed to the container registry, I wish to clean up the images from the self hosted agent to avoid disk space issues in the future. Is there a Docker task to cleanup/remove the built image? In the azure build pipeline, how to cleanup the docker image from self hosted agent once it is pushed?

Source: StackOverflow