Configure Docker

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 2 template, Docker Compose, and Magento Commerce Cloud ece-tools package.

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

  • PHP: magento/magento-cloud-docker-php
    • PHP-CLI - version 7 and later
    • PHP-FPM - version 7 and later
  • NGINX: magento/magento-cloud-docker-nginx
  • Varnish: magento/magento-cloud-docker-varnish

The ece-tools package provides a docker:build command to generate the Docker Compose configuration. Also, you can specify a version using one of the following options:

  • PHP: --php
  • NGINX: --nginx
  • MariaDB: --db

Launch Docker configuration

You can use the ece-tools package to generate the Docker compose configuration and deploy Magento Commerce Cloud in a Docker container.

  • If you use ece tools v2002.0.13 or later, Magento Commerce Cloud deploys to a read-only file system in the Docker container, which mirrors the read-only file system deployed in the Production environment. This version also provides a ` docker:config:convert` command to convert PHP configuration files to Docker ENV files.

  • If you use ece-tools v2002.0.12, Magento Commerce Cloud deploys to a writeable file system in the Docker container. This version does not support the docker:config:convert command.

To launch Docker with ece-tools v2002.0.13 and later:

  1. Download a template from the Magento Cloud repository.

  2. Add your credentials to the auth.json file.

  3. Install the template dependencies.

    composer install
    

    You can use the --ignore-platform-reqs option to bypass restrictions related to the PHP version.

  4. In your local environment, start the Docker configuration generator.

    vendor/bin/ece-tools docker:build
    
  5. Copy the raw configuration files.

    cp docker/config.php.dist docker/config.php
    
    cp docker/global.php.dist docker/global.php
    
  6. Convert the PHP configuration files to Docker ENV files.

     vendor/bin/ece-tools docker:config:convert
    

    This command generate the following Docker ENV files:

    • docker/config.env
    • docker/global.env
  7. Build files to containers and run in the background.

    docker-compose up -d --build
    
  8. Install Magento in your Docker environment.

    • Build Magento in the Docker container:

        docker-compose run build cloud-build
      
    • Deploy Magento in the Docker container:

        docker-compose run deploy cloud-deploy
      
  9. Access your local Magento Cloud template by opening one of the following secure URLs in a browser:

To launch Docker with ece-tools v2002.0.12:

  1. Download a template from the Magento Cloud repository.

  2. Add your credentials to auth.json file.

  3. Install the template dependencies.

    composer install
    

    You can use the --ignore-platform-reqs option to bypass restrictions related to the PHP version.

  4. In your local environment, start the Docker configuration generator.

    vendor/bin/ece-tools docker:build
    
  5. Copy the configuration files.

    cp docker/config.env.dist docker/config.env
    
    cp docker/global.env.dist docker/global.env
    
  6. Build files to containers and run in the background.

    docker-compose up -d --build
    
  7. Install Magento. This step may take some time to complete.

    docker-compose run cli magento-installer
    
  8. Access your local Magento Cloud template by opening the following URL in a browser:

    http://localhost:8080

Stop and remove the Docker configuration

Remove all components of your local Magento Cloud Docker instance including containers, networks, volumes, and images.

docker-compose down

Automate integration testing

Installing Magento Commerce Cloud in a dedicated Docker environment presents an opportunity for you to customize the following features and capabilities to implement automated integration testing:

  • 2-layer configuration for Docker build and Travis CI
  • Customizable Docker Compose file to support a wide range of environment sets
  • Flexible permissions
  • Easy local setup and implementation