Problem with parallel docker build

I deployed 2 instances of drone-agent using docker-compose and at the moment when both agents were building and deploying docker image to GCR(using plugins/gcr) one of the agents failed with the following error:

Error response from daemon: a prune operation is already running
time="2018-10-17T09:24:10Z" level=fatal msg="exit status 1"

Is it expected behavior?

just to clarify, did you deploy two drone agents on the same server? If so, this is not necessary. You can deploy a single agent per-server, and use the DRONE_MAX_PROCS=2 if you want to allow two builds to run concurrently. Note that this has nothing to do with the error you posted.

are you mounting the host machine docker socket when you use the plugin? If yes, please note that this is not recommended.

Thank you for your reply!


Do you mean that this problem can occur even if I will set DRONE_MAX_PROCS=2 ?

Yes. I am doing it for caching docker layers

Correct, I’m just pointing out that you don’t need to install two agents on the same machine. This is just general advice :slight_smile:

Mounting the host machine Docker socket is not recommended, since this plugin was explicitly created to use Docker-in-Docker, to avoid both security issues and race conditions on the host machine (as you are experiencing).

I recommend reading this thread for more details. You can actually use a caching plugin to cache your layers as a safer alternative to mounting the host machine socket.

Alternatively, you can use purge: false which instructs the plugin to disable the docker prune command. Note that you would still be using the plugin in a manner that is unsupported, and you could still run into issues, but it would solve the particular error you posted above.

I hope this helps!

1 Like

Thank you! I will check it!