A collection of Docker images for running Magento application web servers and command line tools.
7.4-apache
(7.4/apache/Dockerfile)7.4-cli
(7.4/cli/Dockerfile)7.4-fpm
(7.4/fpm/Dockerfile)7.3-apache
(7.3/apache/Dockerfile)7.3-cli
(7.3/cli/Dockerfile)7.3-fpm
(7.3/fpm/Dockerfile)7.2-apache
(7.2/apache/Dockerfile)7.2-cli
(7.2/cli/Dockerfile)7.2-fpm
(7.2/fpm/Dockerfile)7.1-apache
(7.1/apache/Dockerfile)7.1-cli
(7.1/cli/Dockerfile)7.1-fpm
(7.1/fpm/Dockerfile)7.0-apache
(7.0/apache/Dockerfile)7.0-cli
(7.0/cli/Dockerfile)7.0-fpm
(7.0/fpm/Dockerfile)5.6-apache
(5.6/apache/Dockerfile)5.6-cli
(5.6/cli/Dockerfile)5.6-fpm
(5.6/fpm/Dockerfile)5.5-apache
(5.5/apache/Dockerfile)5.5-cli
(5.5/cli/Dockerfile)5.5-fpm
(5.5/fpm/Dockerfile)
Since Magento requires several services working together, it recommended to use docker-compose with these images.
See docker-compose.yml for a sample configuration.
All images have sendmail installed for emails, however it is not enabled by default. To enable sendmail, use the following environment variable:
ENABLE_SENDMAIL=true
Note: If sendmail has been enabled, make sure the container has a hostname assigned using the hostname
field in docker-compose.yml
or --hostname
parameter for docker run
. If the container does not have a hostname set, sendmail will attempt to discover the hostname on startup, blocking for a prolonged period of time.
Xdebug is installed and enabled on all the images by default. To configure it for remote debugging, start
the container with the following environment variable set (replacing the {}
placeholders with appropriate values):
XDEBUG_CONFIG="remote_connect_back=1 remote_enable=1 idekey={IDEKEY}"
Note: If you're using PhpStorm, your IDE Key is probably phpstorm
.
The cli
images have a number of useful Magento tools pre-installed:
- composer - Install and manage PHP package dependencies
- mageconfigsync - Backup and restore Magento System Configuration
- magedbm - Create development backups of the Magento database using S3 and import them
- magemm - Sync media images from an S3 backup
- modman - Install Magento extensions
- magerun - Run command line commands in Magento
All of the installed tools run in the working directory of the container, so don't forget to set it using the working_dir
service configuration option in docker-compose.yml
or the --workdir
parameter to docker run
.
Some of the commands use additional environment variables for configuration:
AWS_ACCESS_KEY_ID
(magedbm, magemm) Credentials for S3 connectionsAWS_SECRET_ACCESS_KEY
(magedbm, magemm) Credentials for S3 connectionsAWS_REGION
(magedbm, magemm) S3 region to useAWS_BUCKET
(magedbm) S3 bucket to use for database backupsAWS_MEDIA_BUCKET
(magemm) S3 bucket to fetch media images from
A lot of the configuration for each image is the same, with the difference being the base image that they're extending from. For this reason we use php
to build the Dockerfile
from a set of templates in src/
. The Dockerfile
should still be published to the repository due to Docker Hub needing a Dockerfile
to build from.
To build all Dockerfile
s, run the builder.php
script in the php:7
Docker image:
docker run --rm -it -v $(pwd):/src php:7 php /src/builder.php
The build configuration is controlled by the config.json
file. Yeah element in the top level hash is a new build target, using the following syntax:
"<target-name>": {
"version": "<php-version>",
"flavour": "<image-flavour>",
"files": {
"<target-file-name>": {
"<template-variable-name>": "<template-variable-value>",
...
},
}
The target files will be rendered in the <php-version>/<image-flavour>/
directory.
The source template for each target file is selected from the src/
directory using the following fallback order:
<target-file-name>-<php-version>-<image-flavour>
<target-file-name>-<php-version>
<target-file-name>-<image-flavour>
<target-file-name>
Individual templates may include other templates as partials.