A collection of Docker images for running Magento 2 through nginx and on the command line.
cp composer.env.sample composer.env
# ..put the correct tokens into composer.env
mkdir magento
docker-compose run cli magento-installer
docker-compose up -d
docker-compose restart
Configuration is driven through environment variables. A comprehensive list of the environment variables used can be found in each Dockerfile
and the commands in each bin/
directory.
PHP_MEMORY_LIMIT
- The memory limit to be set in thephp.ini
MAGENTO_RUN_MODE
- Valid values, as defined inMagento\Framework\App\State
:developer
,production
,default
.MAGENTO_ROOT
- The directory to which Magento should be installed (defaults to/var/www/magento
)COMPOSER_GITHUB_TOKEN
- Your GitHub OAuth token, should it be neededCOMPOSER_MAGENTO_USERNAME
- Your Magento Connect public authentication key (how to get)COMPOSER_MAGENTO_PASSWORD
- Your Magento Connect private authentication keyDEBUG
- Toggles tracing in the bash commands when exectued; nothing to do with Magento`PHP_ENABLE_XDEBUG
- When set totrue
it will include the Xdebug ini file as part of the PHP configuration, turning it on. It's recommended to only switch this on when you need it as it will slow down the application.UPDATE_UID_GID
- If this is set to "true" then the uid and gid ofwww-data
will be modified in the container to match the values on the mounted folders. This seems to be necessary to work around virtualbox issues on OSX.
A sample docker-compose.yml
is provided in this repository.
A number of commands are baked into the image and are available on the $PATH
. These are:
magento-command
- Provides a user-safe wrapper around thebin/magento
command.magento-installer
- Installs and configures Magento into the directory defined in the$MAGENTO_ROOT
environment variable.
It's recommended that you mount an external folder to /root/.composer/cache
, otherwise you'll be waiting all day for Magento to download every time the container is booted.
CLI commands can be triggered by running:
docker-compose run cli magento-installer
Shell access to a CLI container can be triggered by running:
docker-compose run cli bash
- In order to achieve a sane environment for executing commands in, a
docker-environment
script is included as theENTRYPOINT
in the container.
Thanks to Mark Shust for his work on docker-magento2-php that was used as a basis for this implementation. You solved a lot of the problems so I didn't need to!