How to prevent docker build running multiple times in parallel for the same tag?

I have a CI build server (Bamboo) that runs my builds in a docker container. Prior to executing docker run, it will do a docker build to make sure the image is up to date (the Dockerfile is in version control with the code being built and the build scripts). The issue is that my build server has 4 agents, so it’s possible for builds to happen in parallel. I do not currently version my docker images with tags (I use the default latest tag). When 2 builds kick off at the same time, and both need to rebuild the image, how do I prevent docker build from running twice on the same tag? Ideally, docker would force the 2nd agent to wait on the docker build command until the first one finishes. What is the inherent danger in this? Is it just wasteful or is there more to it? What’s the proper way to manage parallel builds that automate docker image rebuilds?