A simple Drupal Docker setup
- Git clone the repo. I recommend using
git clone [email protected]:dgading/drupal_compose.git project-name
to keep your evironments separate. - In terminal open the new directory.
- Run
docker-compose build
to build the server container. It is a PHP 7.1 Apache build. This is based on the Drupal Composer project and all Core and Contrib modules added in the composer.json file will be installed in this step. - Run
docker-compose up
to see all processes as they run ordocker-compose up -d
to run the containers in the background. - In your browser, open the default server at
http://localhost:9000
. - Start the Drupal installation process. The default settings are:
- MySql name: root
- MySql user: root
- MySql password: example
- In advanced dropdown, change
localhost
tomysql
- Continue with installation as normal
- Run
docker ps
. - Copy the Container ID of the php contianer (it will be named something like drupalcompose_php).
- Run
docker exec -it <container id> bash
. - This will open the container at
/www/var/html
.
Drush is setup to run in the Docker environment and not from your local machine. Drush is available from within the web
directory in the PHP container.
All modules and patches should be added through composer require
or composer install
.
All custom module and themes should be worked on locally and their volumes will be synced with the Docker environments.
Using a tool like Sequel Pro add the following connection details to the Standard tab.
- Host => localhost or 127.0.0.1
- Username => root
- Password => example
- Port => 3306 or whatever you have on line 15 in docker-compose.yml
If you want command line access:
- Find the mysql container with
docker ps
. - Log into the container using
docker exec -it <container id> bash
- Once in the container, run
mysql -u root -p
- If you are still using the defaults, enter
example
at the prompt and start mysqling.