The following containers provide the services required to build, deploy and run Magento Commerce sites.
See Service configuration options to customize container configuration when you build the Docker compose configuration file.
Container name: db
Docker base image: mariadb, MySQL
You can configure the database container to use either MariaDB or MySQL for the database. The default configuration uses the mariadb image and includes the following volumes:
To use MySQL for the database, add the
--db image option when you generate the Docker Compose configuration file. See Service configuration options.
When a database container initializes, it creates a new database with the specified name and uses the configuration variables specified in the docker-compose configuration. The initial start-up process also executes files with
.sql.gz extensions that are found in the
/docker-entrypoint-initdb.d directory. Files are executed in alphabetical order. See mariadb Docker documentation.
To prevent accidental data loss, the database is stored in a persistent
magento-db volume after you stop and remove the Docker configuration. The next time you use the
docker-compose up command, the Docker environment restores your database from the persistent volume. You must manually destroy the database volume using the
docker volume rm <volume_name> command.
You can inject a MySQL configuration into the database container at creation by adding the configuration to the
docker-compose-override.yml file using any of the following methods:
Use a mount to add a custom
my.cnffile to the
servicessection in the
1 2 3
db: volumes: - path/to/custom.my.cnf:/etc/mysql/conf.d/custom.my.cnf
Add a custom
custom.cnffile to the
cp custom.cnf .docker/mysql/mariadb.conf.d
Add configuration values directly to the
1 2 3 4
services: db: environment: - innodb-buffer-pool-size=134217728
See Manage the database for details about using the database.
Container name: elasticsearch
Docker base image: magento/magento-cloud-docker-elasticsearch
The Elasticsearch container for Magento Cloud Docker is a standard Elasticsearch container with required plugins and configurations for Magento Commerce.
--es-env-var option to customize the Elasticsearch container when you generate the Docker Compose configuration file. You can set Elasticsearch options and specify the environment variables to apply when the container starts, such as the heap size for JVM.
1 php vendor/bin/ece-docker build:compose --es-env-var=ES_JAVA_OPTS="-Xms512m -Xmx512m" --es-env-var=node.store.allow_mmapfs=false
See Important Elasticsearch configuration in the Elasticsearch documentation for details about available configuration options.
If your Cloud project uses Magento version 2.3.5 or earlier with MySQL search, add the
--no-es option to skip the Elasticsearch container configuration when you generate the Docker Compose configuration file:
ece-docker build:compose --no-es.
analysis-phonetic plugins are installed by default and can not be skipped.
If you use Elasticsearch 6.5 and later, the default Elasticsearch plugins are installed automatically along with any custom plugins added to the
services.yamlfile. When you generate the
docker-compose.yaml file, you can add additional custom plugins to the Docker environment using the
ES_PLUGINS environment configuration option.
The following example adds the
analysis-nori plugins to the Docker environment.
1 2 3 4 services: elasticsearch: environment: - 'ES_PLUGINS=analysis-stempel analysis-nori'
On some Linux systems, when you launch the Docker environment, the Elasticsearch service fails to start and the following error displays:
1 2 ERROR:  bootstrap checks failed : max virtual memory areas vm.max_map_count  is too low, increase to at least 
To fix the error, run the following
sysctl command to increase the memory map area allocation.
1 sysctl -w vm.max_map_count=262144
To permanently update the system setting for
Edit the sysctl configuration file (
etc/sysctl.conf) and set the required value for the
Reboot your system.
Run the following command to verify the change.
The FPM container includes the following volumes:
- Read-only volumes:
- Read/Write volumes:
Customize PHP settings
You can customize PHP service settings for PHP-FPM and CLI containers by adding a
php.ini file to the root directory of your Magento project.
The Cloud Docker deploy process copies the
php.ini file to the Docker environment after applying the default Docker and Magento extension configurations and applies the settings to the FPM and CLI containers.
If you use the
mutagen file synchronization options, the
php.ini file is available only after the file synchronization completes.
Customize PHP extensions
You can add custom PHP extensions and manage their status from the
runtime section of the
.magento.app.yaml file. See PHP extensions. To test custom extensions without updating the Magento Commerce Cloud environment configuration, you can add the custom configuration to the
docker-compose.override.yml. Configuration settings in this file are applied only when you build and deploy to the Docker environment.
Optionally, you can add Xdebug to your Cloud Docker environment to debug your PHP code. See Configure XDebug for Docker.
Container name: mailhog
Docker base image: mailhog
The default Magento Cloud Docker configuration includes the MailHog service as a replacement for the Sendmail service. Sendmail can cause performance issues in the local Docker environment.
By default, MailHog listens on port 1025 for SMTP and port 8025 for the frontend dashboard and API (HTTP). You can change the default ports using the
--mailhog-smtp-port options. When you build the Docker compose configuration, you can change the default ports:
1 ./vendor/bin/ece-docker build:compose --mailhog-smtp-port=1025 --mailhog-http-port=8025
After updating the configuration and restarting the Docker environment, you can connect to the MailHog service from
http://magento2.docker:8025, and use port 1025 for SMTP communication.
If needed, you can disable the MailHog service when you generate the Docker compose configuration:
1 ./vendor/bin/ece-docker build:compose --no-mailhog
Container name: rabbitmq
Docker base image: rabbitmq
The RabbitMQ container for Magento Cloud Docker is a standard RabbitMQ container with no configuration or changes.
Container name: redis
Docker base image: redis
The Redis container for Magento Cloud Docker is a standard container with no customization, no persistence, and no additional configuration.
Connect to and run Redis commands using the redis-cli inside the container:
1 docker-compose run --rm redis redis-cli -h redis
The Test container, based on the magento/magento-cloud-docker-php Docker image, has a writable file system and is used for Magento application testing in the Cloud Docker environment. See Magento application testing.
Container name: tls
Docker base image: magento/magento-cloud-docker-nginx:1.19-1.2.0
8080:80 (Varnish bypass)
By default, the TLS container is included with the Docker Compose configuration. However, you can generate a configuration without TLS by adding the
--no-tls option to the
ece-docker build:compose command.
The TLS termination proxy container facilitates the Varnish SSL termination over HTTPS.
- The default port for TLS communication is
- If you have Varnish installed in the Docker environment, use port
8080:80to bypass caching.
You can change the default port when you generate the Docker configuration file:
./vendor/bin/ece-docker build:compose --tls-port <port-number>
To increase the timeout on this container, add the following code to the
1 2 3 tls: environment: - TIMEOUT=600
The Varnish container simulates Fastly and is useful for testing VCL snippets.
The Varnish service is installed by default. When deployment completes, Magento is configured to use Varnish for full page caching (FPC) for Magento version 2.2.0 or later. The configuration process preserves any custom FPC configuration settings that already exist.
In some cases, you might require a Docker environment without Varnish, for example to debug or run performance tests. You can generate the Docker Compose configuration without Varnish by adding the
--no-varnish option to the
ece-docker build:compose command.
1 ./vendor/bin/ece-docker build:compose --mode="developer" --php <version> --no-varnish
You can specify
VARNISHD_PARAMS and other environment variables using ENV to specify custom values for required parameters. This is usually done by adding the configuration to the
To clear the Varnish cache:
1 docker-compose exec varnish varnishadm ban req.url '~' '.'
The Web container uses NGINX to handle web requests after TLS and Varnish. This container passes all requests to the FPM container to serve the PHP code. See Request flow.
This container provides two NGINX configuration options for building the Docker configuration:
--nginx-worker-processesto set the number of worker processes for NGINX. The default is
--nginx-worker-connectionsto set the maximum number of connections that each worker process can handle simultaneously. The default is
The NGINX configuration for this container is the standard Magento nginx config, which includes the configuration to auto-generate NGINX certificates for the container. You can customize the NGINX configuration by mounting a new configuration file using a volume.
To mount the custom NGINX configuration file using volumes:
On your local host, create a
vhost.confconfiguration files to the new directory.
vhost.conffile, customize the values for variables like
To mount the custom NGINX configuration to the Web container, add the volume configuration to the
1 2 3 4 5 services: web: volumes: - ./.docker/nginx/etc/nginx.conf:/etc/nginx/nginx.conf - ./.docker/nginx/etc/vhost.conf:/etc/nginx/conf.d/default.conf
To mount the custom index.php file using volumes:
- To mount the custom index.php file to the Web container, add the volume configuration to the
1 2 3 4 services: web: volumes: - ./pub/index.php:/app/pub/index.php:ro