Docker parallel build failing. Anyone?

We have Drone CI and using Kubernetes runner, noticed that when using parallel docker build/publish, the builds fail for weird reasons. the most common one is

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
time=“2020-11-23T10:11:19Z” level=fatal msg=“exit status 1”

Anyone facing such issue or know of the fix?

the docker plugins uses docker-in-docker which means it starts a docker daemon inside the container. because all pipeline containers inside a pod share the same network, it is not possible to start multiple docker-in-docker at the same time due to network race conditions. therefore running the docker step in parallel in kubernetes is not possible, due to kubernetes pods sharing the same network space. you would therefore need to run the steps sequentially.

hmm, thanks for the super quick response :slight_smile: Btw what is the reason then it sometimes works and sometimes not? I mean in our case about 70% times it works but not for the rest.

this is because it is a race condition. If two docker-in-docker daemons try to set iptables rules at the exact same time it will fail. It they try to update iptables, but one updates a few hundred milliseconds before the other, it would succeed.

aah right! thanks for the explanation.

note that it may be possible to disable iptables when the daemon starts [1], which may prevent this specific race condition. I would definitely merge a pull request that adds iptables: false as an option to the docker plugin [2] assuming it resolves the problem.


Hmm actually I am not well versed with this, how docker handles iptables and if iptables modification is set to false, then whether there will be any repercussion. Any thoughts?

OK here it is, after all, it was not that much of effort: