This repo contains documentation and example tooling for running Drupal with Docker on OS X.
docker-compose.yaml- sample Docker Compose config filedocker/drupal/Dockerfile- Dockerfile fordrupalcontainerdocker/init- folder for MySQL auto-importpackage.json- NPM scripts for managing Docker Compose and MySQLDOCKER-RUN.md- instructions for running with barebones Docker Run commands
Here are steps for running a Drupal development site using Docker Compose on Mac OS X. (To use docker running commands, see other file).
Start the Docker Desktop daemon before proceeding.
In the included docker-compose.yaml config file, a mysql database container and a drupal web server container are defined. The drupal container is further configured in /docker/drupal/Dockerfile.
Navigate to the codebase folder and launch the app containers with docker-compose up.
The database will automatically import .sql files in your /docker/init folder.
You should now be able to view your site in the browser at http://localhost:8000
You can connect to the database at http://localhost:33060
Exit the Docker Compose session with CMD-C.
You can then restart the containers with docker-compose start, and stop them with docker-compose stop.
Remove the containers with docker-compose down.
For more utilities see the included NPM Scripts.
Docker Run:
docker:up- launch Docker Compose containersdocker:start- restart app containersdocker:stop- stop app containersdocker:down- remove app containersdocker:reload- remove and launch app containersdocker:kill- stop and remove all containers
Docker Utils:
docker:list- list containersdocker:logs- display logs from app containers
Docker Images:
docker:images- list imagesdocker:build- regenerate custom imagesdocker:rebuild- remove all containers, build images and relaunch app containersdocker:rmi- remove all images
Drush Utils:
drush:help- show Drush commandsdrush:status- show Drupal installation infodrush:login- generate one-time Drupal admin login URLdrush:modules- display info on Drupal modules
Bash Shell:
shell:drupal- bash shell fordrupalcontainershell:mysql- bash shell formysqlcontainer
MySQL Utils:
mysql:dbs- list mysql databasesmysql:tables- list Drupal tablesmysql:empty- empty Drupal databasemysql:shell- launch MySQL shell
After launching the containers, you can run database commands:
- To see databases, run
docker exec mysql mysql --user="drupal" --password="drupal" --database="drupal" --execute="show databases;" - To see tables:
docker exec mysql mysql --user="drupal" --password="drupal" --database="drupal" --execute="use drupal; show tables;" - To empty database:
docker exec mysql mysql --user="drupal" --password="drupal" --database="drupal" --execute="drop database drupal; create database drupal" - To run MySQL commands on your database, launch a terminal within a second container instance:
docker run -it --network drupal --rm mariadb mysql -hmysql -udrupal -p
To connect to the database via SQL Pro (or other app), create a new connection with these values:
- host: 127.0.0.1
- username:
drupal - password:
drupal - database:
drupal - port: 33060