Drush not working on a docker based enviroment on ubuntu 16.04 I have set up a local dev docker environment with the Drupal social distribution. My issue is that Drush commands do not work and whenever I run a Drush command, it takes approximately 45 seconds to get a response. Generally, the output is always the same or similar to the following.


  [warning] proc_open(): unable to dup File-Handle for descriptor 2 - Too many open files exec.inc:243
  [warning] proc_get_status() expects parameter 1 to be resource, boolean given exec.inc:244
  [warning] proc_close() expects parameter 1 to be resource, boolean given exec.inc:245


I am unsure what the reason for this response is or what I may have done wrong to get to this point. I tried googling the warning errors but without getting a usable answer. If someone has had similar problems and managed to solve it, some directions on what to do would be appreciated.

I also want to state that outside the docker environment I have setup multiple Drush setups; Drush commands work normally without any delay outside of it. 

My environment is Ubuntu 16.04 with 15.5 GB RAM, i7-6500U CPU 2.5 GHz x4 Processor, 200GB DDR disk.

I googled some more and found out that for running Drush inside a docker environment you need docker-compose run drush "drush command here" since Drush container gets run only for one specific command and then shuts back down, but now I am getting different errors.

docker-compose run drush cache-rebuild --verbose --debug gives this as output.


  Phar detected. Proceeding to drush_main().Drush preflight prepare loaded autoloader at  [0 sec, 2.92 MB] [preflight]
  Starting Drush preflight. [0 sec, 2.92 MB] [preflight]
  Cache HIT cid: 8.1.2-commandfiles-0-9c75c37463d39480ab97163ab2be3712 [0.01 sec, 2.96 MB] [debug]
  Scanning into /etc/drush for /.*aliases.drush(8|)rc.php$/ [0.02 sec, 5.02 MB] [debug]
  Scanning into /etc/drush for /self.alias.drush(8|)rc.php$/ [0.02 sec, 5.02 MB] [debug]
  Scanning into phar:///usr/local/bin/drush/includes/.. for /.*aliases.drush(8|)rc.php$/ [debug] [0.02 sec, 5.02 MB]
  Scanning into phar:///usr/local/bin/drush/includes/.. for /self.alias.drush(8|)rc.php$/ [debug] [0.03 sec, 5.03 MB]
  Scanning into /root/.drush for /.*aliases.drush(8|)rc.php$/ [0.04 sec, 5.03 MB] [debug]
  Scanning into /root/.drush for /self.alias.drush(8|)rc.php$/ [0.04 sec, 5.03 MB] [debug]
  Bootstrap to phase 0. [0.05 sec, 6.01 MB] [bootstrap]
  Bootstrap to phase 2. [0.05 sec, 6.01 MB] [bootstrap]
  Command cache-rebuild needs a higher bootstrap level to run - you will need to invoke drush from a more functional Drupal environment to run this command. [error] [0.05 sec, 6.01 MB]
  Command cache-rebuild requires Drupal core version 8+ to run. [0.05 sec, 6.01 MB] [error]
  The drush command 'cache-rebuild' could not be executed. [0.05 sec, 6.01 MB] 


Hope that gives you a clue of what is the matter here.
When you run docker run ... or docker-compose run, Drush is running in the context of the container, not your host machine. So when it needs stuff like DB credentials, aliases, ssh keys, it looks for them in the container. If Drush cannot find such things in the container, Drupal cannot fully connect to Drupal and you get an error, usually the bootstrapping one.

I have a feeling your code isn't mounted to the Drush container, based on the fact that the alias scanning isn't picking up anything custom, only the usual alias paths. If the code is mounted, then probably the Drush container does not have the DB credentials. Do a drush status to check if everything is fine.