title: How To Run Docker Commands Asynchronously?
body: <p>Docker in it's current form places any docker commands into a work queue and executes them one at a time and sequentially (synchronously). This means if you're creating a single threaded API (node.js) that incorporates docker commands such as standing up containers or downloading images it will very quickly get backed up and overload the docker work queue. I've gotten that far. The question is how could I re-model docker to handle commands asynchronously?</p>
  
  <p>I care less about getting updates as to the commands status or even being able to supply a callback function for when it's done. My primary goal is to be able to rapidly call docker to stand up or execute commands in high volumes without affecting the response times for API.</p>
  
  <p><strong>Some thoughts -</strong> </p>
  
  <ol>
  <li>Scale horizontally with more VM's</li>
  </ol>
  
  <p>Doesn't efficiently utilize each virtual machine. Costly. Inelegant solution.</p>
  
  <ol start="2">
  <li>Initialize more docker daemons and balance tasks amongst available daemons.</li>
  </ol>
  
  <p>Still not truly asynchronous. Additionally the various docker daemons are unable to share resources such as images. So if you have 10 docker daemons that want to run an Ubuntu container then you will need 10 separate ubuntu images which will take up 10 times the space of the original ubuntu image size.</p>
  
  <ol start="3">
  <li>Async Docker Client - <a href="https://github.com/tulayang/asyncdocker" rel="nofollow noreferrer">https://github.com/tulayang/asyncdocker</a>
  I have been unable to get this up and running even on the NIM docker container. Additionally it's written in NIM. Also not entirely clear that this is what I'm looking for or if it's just referencing async http requests within docker.</li>
  </ol>