Skip to content

Instantly share code, notes, and snippets.

@mortenson
Last active January 7, 2020 11:53
Show Gist options
  • Save mortenson/48d16568147a710bedf94506f837733a to your computer and use it in GitHub Desktop.
Save mortenson/48d16568147a710bedf94506f837733a to your computer and use it in GitHub Desktop.
Quick way to proxy Drush commands to your Docker container
#!/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 $@
@marcoscano
Copy link

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.

@mortenson
Copy link
Author

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, 😄

@leymannx
Copy link

leymannx commented Jan 7, 2020

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