CI pipelines, concurrency and build results possibly overwriting each-other
I am using AzureDevOps and the trick we use when naming containers is to add build number to the label

namespace/application:branch-name-bulidNumber


So in your case, you could try gitlab variable CI_CONCURRENT_PROJECT_ID

After comment

for images clean-up you can use:

  docker image prune --all --filter until=48h 


As docker system prune and docker image prune have the until filter. So docker image prune --all --filter until=48h would remove all (not just dangling) images that were created more than 48 hours ago. Hopefully that helps. source here