[SOLVED] How to Setup 'Docker4Drupal' in Ubuntu?

| | 2 min read

Docker is an open source platform for system administrators and developers to build, ship and to run distributed applications, whether its on the cloud, data center VMs, or on the laptops. Docker helps to automate the deployment of Linux applications inside software containers.

Docker4Drupal (A native docker-based local environment for Drupal) is an open source initiative by Wodby to setup Drupal local environments. Docker4Drupal is supported for both Drupal 7 and Drupal 8 versions.

This write-up helps you to set up a local Drupal environment in seconds.

You have to install the Docker for Linux to start with.

For the Linux platform, you have to additionally install Docker Compose. You can install the docker-compose by the following command in your Ubuntu terminal.

$ pip install docker-compose

Clone the Docker4Drupal to your local machine by running the following command in your Ubuntu terminal or alternatively download the package.

$ git clone https://github.com/Wodby/docker4drupal.git

Using the Docker compose file (docker-compose.yml) we can set up a local environment for Drupal using a native Docker app on Linux, Mac OS X, and Windows as well.

Before running the compose file, you have to update the configurations to meet your needs. You can also have a look at the available containers in the Drupal bundle.

Place the Docker compose file in your Drupal Webroot. Navigate to the Drupal webroot in the terminal and run the compose file using the following command.

$ docker-compose up -d

You will be able to access the Drupal site at http://localhost:8000, phpMyAdmin at http://localhost:8001, Mailhog at http://localhost:8002, Apache Solr at http://localhost:8003 and Memcache Admin at http://localhost:8006/index.php by default (If you have not customized the port numbers in compose file).

Accessing containers

You can connect to any container in the Drupal bundle by executing the following command. Replace SERVICE with the name of the service (e.g. PHP, MariaDB, Nginx, etc).

$ docker-compose exec SERVICE sh

Hope this helps! Please feel free to get in touch with us if you need any further assistance.