Initially, we need to define the configuration for our Nginx web server. Completing the Installation Through the Web Interface.Modifying the Web Server Configuration and Service Definition.Obtaining SSL Certificates and Credentials.How to install Drupal with Docker Compose? Let us today discuss the steps to install Drupal with Docker Compose. Install of Drupal can be simplified with the use of tools like Docker and Docker Compose.Īs a part of our Server Management Services, we help our Customers with Docker related requests regularly. You can bash alias that to be something less keyboard intensive, ofcourse.Drupal requires installing the LAMP or LEMP stack, thus, installing individual components is a time-consuming task. You can now run Drush commands on the container like this: docker exec drush. Or - for shared control with the host, you can consider having it mounted as a volume in your docker-compose.yml. You can transport these aliases into the container by having something like this in your Dockerfile: # Push our aliases into the container ~/.drushĪDD /path/to/your/drush-aliases/* ~/.drush/ As an example, look at these aliases and consider the entire setup as a reference implementation: RUN php -r "readfile('') " > drush & chmod +x drush & mv drush /usr/bin/įor actual usage, you're better off shipping separate Drush aliases for usage - both from the container and the host (via public key SSH). # Get a global installation of Drush on the web / drupal container For that, add a one liner in your Dockerfile. In order to make Drush work effectively - you're better off running it from within the container that is running Drupal. Example: FROM drupal:8.0.4-apacheĥ) Use another container with drush and volume it to the Drupal container using the docker-compose.yml. > drush & chmod +x drush & mv drush /usr/local/bin'Ĥ) Install Drush on Drupal by creating a Docker image (using a Dockerfile). ģ) Install Drush into Drupal container after it has run. This value changes every time the container is updated, so to make it persist, the hostname is explicitely stated in docker-compose.yml, se above.Įdit: I've made a small project to host a drupal + drush + phpmyadmin development environment based on this: Īs always with Docker there are many options to use drush.īut notice that in order drush to have access to the database (eg mysql) there should be volumes from mysql container on Drupal such as: version: '2'ġ) Mount your local drush to the Drupal container: version: '2'Ģ) Create a data only docker image for drush and volume the executable to your Drupal container. SHOW VARIABLES WHERE Variable_name = 'hostname' (taken form this) The alternate hostname is the hash id of the running container, which can be found by running the sql (from phpmyadmin for example): The out commented line after 'host' => 'mysql' is a previous attempt taken from another SO answer and illustrates the problem, drush use the command line server API which is different from whatever drupal uses. 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', Here is the relevant section from settings.php: $databases = array ( But the 'host' key in the databases array is interpreted differently by drupal and drush apparently. The second problem above is particularly devilish since drush use the configuration from settings.php to connect to mysql. Why explicitly setting the hostname works The important packages are curl (obviously) and mysql-client.Īnd these are the relevant parts of the docker-compose.yml: version: '3.3' RUN apt-get clean & rm -rf /var/lib/apt/lists/* RUN composer global require drush/drush & \ Ln -s /root/.composer/vendor/bin/drush /usr/local/bin/drush Mv composer.phar /usr/local/bin/composer & \ RUN rm /bin/sh & ln -s /bin/bash /bin/sh & \Īpt-get update & apt-get install -no-install-recommends -y \ This is my Dockerfile: FROM drupal:8.3.7-apache The mysql hostname needs to be explicitly set in the docker-compose file (or docker run command). The package mysql-client is needed to connect remotely to the database (since we are running this on a local docker network). That works somewhat, if you exec into the container you can run drush status, but it won't connect to the mysql server. Like OP I never got the drush image to work on the local docker network so it seemed simpler to me to bundle drush via composer with the drupal image (see Dockerfile below). I have spent way too much time getting this to work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |