How to remove metadata labels added by Docker Task in Azure Pipelines?

When building a docker image in Azure Pipelines the Docker Task adds traceability related metadata to the image in the form of the following labels:

  • com.azure.dev.image.build.repository.uri
  • com.azure.dev.image.build.repository.name
  • com.azure.dev.image.build.sourcebranchname
  • com.azure.dev.image.build.sourceversion
  • com.azure.dev.image.system.teamfoundationcollectionuri
  • com.azure.dev.image.system.teamproject
  • com.azure.dev.image.build.definitionname
  • com.azure.dev.image.build.buildnumber
  • com.azure.dev.image.build.requestedfor

I don’t want this metadata in my public docker image.

How can I prevent Azure Pipelines from adding metadata to my images?
Or how do I remove those labels from the image built?

Source: StackOverflow