-
-
Save mortenson/48d16568147a710bedf94506f837733a to your computer and use it in GitHub Desktop.
| #!/bin/bash | |
| # Save this to a file named "drush" (not "drush.sh") and put it in the same | |
| # directory as your docker-compose file. Replace "SERVICE" with your docker | |
| # container's name. | |
| # Now every time you run "drush" from this directory, it runs drush inside | |
| # your container instead. Cool! | |
| docker-compose exec SERVICE drush $@ |
I don't think so, Drush is clever and will prefer local versions of the drush binary if it detects one. So you may start running drush globally (/usr/local/bin), but that will find this drush script and pass everything to it instead.
As an alternative approach, I've been using what Janez suggested here: https://janezurevc.name/drupal-dev-environment-on-docker, having a drush container linked to the web container. It's been working great for me so far.
Nice - I was doing something similar but got really tired of writing docker-compose run --rm drush, or even aliases like docker-drush. My brain still thinks drush should always work if I'm in a webroot, even if that webroot is mounted as a volume in a docker container, π
You are a goddamn genius! Thanks for sharing. πββοΈ
Doesn't "this directory" need to be in the $PATH ?