Last active
January 7, 2020 11:53
-
-
Save mortenson/48d16568147a710bedf94506f837733a to your computer and use it in GitHub Desktop.
Quick way to proxy Drush commands to your Docker container
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 $@ |
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. 🙇♂️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.