- Docker engine 1.13+ / 17+: https://docs.docker.com/engine/installation/ (without need to sudo)
- Docker compose 1.17+: https://docs.docker.com/compose/install/
Focus on simple set-up, based on Docker official images and lightweight Alpine Linux to ease maintenance.
Every service is optional as declared in the yml file.
- Adminer (Database management)
# Clone this project. git clone https://github.com/Mogtofu33/docker-compose-drupal.git docker-drupal cd docker-drupal # Create your docker compose file from template. cp docker-compose.tpl.yml docker-compose.yml # (Optional) choose a db, remove or add services, add your composer cache folder. # But you can let it as it for a default quick stack. vi docker-compose.yml # Create your config file from template. cp default.env .env # Edit your configuration if needed, recommended on Unix add your local uid/gid. vi .env # Check the config and fix if needed. docker-compose config # For an existing Drupal 8 project, create folders and copy it in # Note that based on Composer template you we root should be under _drupal/web_ # folder. If not you need to adapt Apache vhost config from config/apache/vhost.conf mkdir -p data/www/drupal cp -r _YOUR_DRUPAL_ data/www/drupal/ # Launch the containers (first time include downloading Docker images). docker-compose up --build -d # Quick check logs to ensure startup is finished, mostly Apache. docker-compose logs apache
Note: If you have a permission denied from now it's because of owner of /var/run/docker.sock
, run docker and docker-compose commands as sudo.
http://localhost
http://localhost:8181
If you have copy an existing Drupal project, you can import the database from the adminer link in the dashboard.
Setup a new Drupal 8 based on a composer template (yes it's slower, but this is the good way!) with user Apache.
Based on Drupal 8 template, include Drush and Drupal console, using Composer in the docker service:
docker exec -it -u apache dcd-php \ composer create-project drupal-composer/drupal-project:8.x-dev /var/www/localhost/drupal --stability dev --no-interaction
OR locally if you have Composer, from this project root:
composer create-project drupal-composer/drupal-project:8.x-dev data/www/drupal --stability dev --no-interaction
To use PostGresSQL change mysql to pgsql
docker exec -it -u apache dcd-php /var/www/localhost/drupal/vendor/bin/drush -y si \ --root=/var/www/localhost/drupal/web \ --account-name=admin \ --account-pass=password \ --db-url=mysql://drupal:drupal@mysql/drupal
http://localhost # Login with admin / password http://localhost/user/login
docker exec -it -u apache dcd-php \ composer -d=/var/www/localhost/drupal require \ drupal/admin_toolbar drupal/ctools drupal/pathauto drupal/token drupal/panels
docker exec -it -u apache dcd-php \ /var/www/localhost/drupal/vendor/bin/drush -y en \ --root=/var/www/localhost/drupal/web \ admin_toolbar ctools ctools_block ctools_views panels token pathauto
docker exec -it -u apache dcd-php \ ls -lah /var/www/localhost/drupal
docker exec -it -u apache dcd-php bash
docker-compose stop && docker-compose down
rm -rf data
You can find a script in scripts/get-tools.sh folder to download or update all tools.
cd THIS_PROJECT/scripts/ chmod +x get-tools.sh ./get-tools.sh
When accessing http://localhost:8181/ error:
Fatal error: Uncaught Http\Client\Socket\Exception\ConnectionException: Permission denied in phar:///var/www/dashboard/dashboard.phar/vendor/php-http/socket-client/src/Client.php:114...
Solution, fix local /var/run/docker.sock permission to local user:
chown $USER:$USER /var/run/docker.sock