Docker development environment

Magento Commerce Cloud provides a Docker environment option for those who use their local environment for development, test, or automation tasks. The Magento Commerce Cloud Docker environment requires three, essential components: a Magento Commerce v2 template, Docker Compose, and Magento Commerce Cloud ece-tools package.

Container architecture

The Magento Cloud Docker repository contains build information for the following Docker images:

Web container

The web container works with the PHP-FPM to serve PHP code, the DB image for the local database, and the Varnish image to send requests and cache the results.

CLI container

The CLI container is based on a PHP-CLI image that provides magento-cloud and ece-tools commands to perform file system operations. The CLI container depends on the DB image for the local database and the Redis image.

  • build—extends the CLI container to perform operations with writable filesystem, similar to the build phase
  • cron—extends the CLI container to run cron

    • The setup:cron:run and cron:update commands are not available on Cloud and Docker for Cloud environment
    • Cron only works with CLI container to run ./bin/magento cron:run command
  • deploy—extends the CLI container to use read-only file system, similar to the deploy phase

As an example, to run the ece-tools ideal-state command:

docker-compose run cli ece-command wizard:ideal-state
 - Your application does not have the "post_deploy" hook enabled.
The configured state is not ideal

Cron container

The Cron container is based on PHP-CLI images, and executes operations in the background immediately after the Docker environment start.

View cron log

docker-compose run cli bash -c "cat /var/www/magento/var/log/magento.cron.log"

Database container

The database container is based on the mariadb:10 image.

Importing a database dump

To import a database dump, place the SQL file into the docker/mysql/docker-entrypoint-initdb.d folder. The ece-tools package imports and processes the SQL file the next time you build and start the Docker environment using the docker-compose up command.

Although it is a more complex approach, you can use GZIP by sharing the .sql.gz file using the docker/mnt directory and importing it inside the Docker container.

Sharing data between host machine and container

You can share files easily between your machine and a Docker container by placing the files in the docker/mnt directory. You can find the files in the /mnt directory the next time you build and start the Docker environment using the docker-compose up command.