Create a Docker4Drupal image with support for Emacs editing set up (HTML, CSS, PHP files). Drupal4Docker has Portainer support.

My Emacs configuration is used as an example to configure Emacs in the container.


Initially follow instructions at Local environment with Docker4Drupal.

Add GUI support

Add GUI support to the Docker compose file by adding two lines to the volumes under nginx, below the existing line - ./:/var/www/html, as follows:

 - ./:/var/www/html
 - /tmp/.X11-unix/:/tmp/.X11-unix/:ro
 - ~/.Xauthority:/home/wodby/.Xauthority:rw

This is inspired by the following YouTube video: How to Run a Graphical Application from a Container? Yes, I Know IT! Ep 20.

Compose up

To build images and bring them up.

$ docker-compose up -d --build

Allow for some time to let it settle.

Visit http://drupal.docker.localhost:8000/ for your site. Visit http://portainer.aboveurl/ for the Portainer interface.

Connect to development image

Execute a root bash shell in the container to install required additional packages.

$ docker exec -u 0 -ti my_drupal8_project_nginx /bin/bash


From the root bash shell in the container:

bash-4.4# apk add git emacs-x11 the_silver_searcher ttf-dejavu

bash-4.4# exit

Execute a bash shell in the container to set up Emacs.

$ docker exec -ti my_drupal8_project_nginx /bin/bash

From the bash shell in the container:

/var/www/html$ git clone ~/.emacs.d

/var/www/html$ export DISPLAY=:0

/var/www/html$ emacs --daemon

/var/www/html$ emacsclient -nc web/index.php

If the emacsclient command doesn’t work the first time then restart the Emacs daemon by repeating the emacs --daemon and emacsclient -nc web/index.php commands.

Emacs running