This Docker image is based on the regular Drupal 7 image. It differs in these respects:
- It allows you to mount the container directory
/var/www/html/sites/default/files
as a volume. This is the location where H5P stores its data. - The installation of the default site is done automatically (uses SQLite as database).
- The PHP upload limit is increased (required by H5P).
- The modules H5P and H5PEditor are already installed.
You still need to change the configuration of the H5P module in the settings to enable (library) development mode.
The container is automatically re-built whenever the regular Drupal 7 image is updated (not when H5P is updated).
- Create a local directory called
files
and give everybody write and read permission (as described below). - Execute
sudo docker run --name drupaldev -d -p 8080:80 -v `pwd`/files:/var/www/html/sites/default/files -t sr258/drupal-h5p-docker
- Access Drupal at http://localhost:8080 and get any content type from the H5P Hub to initialize the folders in
files/h5p
. - You can now work with the H5P library files in the
files/h5p
directory (if you've configured the access rights of the directory properly in step 1).
Go to https://docs.docker.com/install/ and install Docker for your system. It is convenient to configure docker so that you can run docker
as a normal user and don't have to use sudo
every time.
To develop H5P libraries in the Docker container you need to be able to modify files inside the running container. The way Docker does this is to mount "volumes" to paths in your file system. You can think of a volume as a symlink between a directory in your local file system and a directory in the container. Drupal stores all H5P data (content and libraries) in /var/www/html/sites/default/files
. You have to mount this path to a local directory. The local directory must be write-accessible to the user www-data
of the Drupal container and you must still be able write its contents from your development user account. To achieve this execute the following from the command line:
mkdir files
sudo chmod -R 777 files
Navigate to the directory in which you've created the files
directory and execute this command to fetch the container from the Docker Hub and execute it:
sudo docker run --name drupaldev -d -p 8080:80 -v `pwd`/files:/var/www/html/sites/default/files -t sr258/drupal-h5p-docker
You can access drupal at http://localhost:8080 (username: admin, password: admin)
Your first step should be to enable the "H5P development mode" and "library development directory" in the settings (see http://localhost:8080/node#overlay=admin/config/system/h5p).
You can now develop your libraries in the directory files/h5p/development
on your local machine. All changes will be automatically synced to the docker container.
To stop the container and remove it from memory, execute the command below. If you restart it later, its execution state will be restored.
sudo docker stop drupaldev
To restart a stopped container execute this command:
sudo docker restart drupaldev
If you want to wipe the whole Drupal container (and all data inside), execute:
sudo docker rm drupaldev
This will not remove the files in the files
directory, as Docker volumes are designed to be persistent independent of container lifetime.