Public | Automated Build

Last pushed: 2 months ago
Short Description
Drush is a command-line shell and scripting interface for Drupal.
Full Description

Drush Docker Container

A Docker container to run Drush, Drupal's command line tool.

Usage

This covers how to run the Drush container through the Docker CLI.

Pull

Pull drush/drush from the Docker repository:

docker pull drush/drush

Alternatively, you can download a specific version of Drush:

docker pull drush/drush:8

Run

To execute Drush directly, run the container with docker run, mounting the /app volume:

docker run -v $(pwd):/app drush/drush
docker run -v $(pwd):/app drush/drush help
docker run -v $(pwd):/app drush/drush --version
docker run -v $(pwd):/app drush/drush status

If you installed a specific version of Drush, run it with:

docker run -v $(pwd):/app drush/drush:8 --version

Development

  1. Download the source:

    git clone https://github.com/RobLoach/drush-docker.git
    cd drush-docker
    
  2. Build one of the images:

    docker build -t drush/drush:8 8
    
  3. Use the Makefile to build and test all images:

    make
    
  4. Visit the drush/drush Docker Hub for build details.

  5. Submit Pull Requests and create issues for new changes and features you'd like to add.

Docker Pull Command
Owner
drush
Source Repository

Comments (11)
nevergone
a year ago

import database dump from host:

docker run -v $(pwd):/app --network {your_container_network_name} --rm drush/drush sqlq --file=dump_file.sql

nevergone
a year ago

Howto import database dump from host?

This does not work:
docker run -v $(pwd):/app --network {your_container_network_name} --rm drush/drush sqlc < dump_file.sql

kostajh
a year ago

@karelbemelmans This works fine for me: docker run --net={your_container_network_name} --rm -it -v $(pwd):/app drush/drush sqlc

karelbemelmans
a year ago

If this container is only able to mount the files directory, and not also connect to the database, how do you intend for this to be actually useful for a Drupal site? You can download modules like this, but running any command that alters config in the database will not work.

tplcom
a year ago

In order to use this image on a docker-compose.yml file see this issue/answer: https://github.com/RobLoach/drush-docker/issues/32#issuecomment-222321265

jehu99
a year ago

i want to use this to work on a www directory which is mounted in a running docker container ("web") as a volume.

On the host machine the mysql container ("db") is reachable due a etc/hosts entry an the exposed standard port 3306.
Using a installed drush works as expected.

If i try to use the drush from this drush container, the Database server host "db" is not reachable.

How can i make the database container "db" reachable for the dockerized drush?

Any hints?

snappytux
2 years ago

I can not run docker run -v $(pwd):/app drush/drush:7 upc -v

Error

nitialized Drupal 7.41 root directory at /app [notice]
Initialized Drupal site default at sites/default [notice]
Executing: mysql --defaults-extra-file=/tmp/drush_TolVnR --database=sathu --host=mysql --silent < /tmp/drush_yu6dOr
Command pm-updatecode needs a higher bootstrap level to run - you [error]
will need to invoke drush from a more functional Drupal environment
to run this command.
The drush command 'upc' could not be executed. [error]
Drush was not able to start (bootstrap) the Drupal database. [error]
Hint: This may occur when Drush is trying to:

  • bootstrap a site that has not been installed or does not have a
    configured database. In this case you can select another site with a
    working database setup by specifying the URI to use with the --uri
    parameter on the command line. See drush topic docs-aliases for
    details.
  • connect the database through a socket. The socket file may be
    wrong or the php-cli may have no access to it in a jailed shell. See
    http://drupal.org/node/1428638 for details.
robloach
2 years ago

@Pirog Matt Parker has added multiple Drush version support! docker pull drush/drush:7

moroland
2 years ago

Docker run syntax is: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
So to run:
docker run -v $(pwd):/app drush/drush

Also it's possible to set the drush version:
docker run -v $(pwd):/app drush/drush:7

littletiger1984
2 years ago

So you have drush running in a container.... Then how do you get it to execute on your Drupal container install?