Docker services containers

The following containers provide the services required to build, deploy and run Adobe Commerce sites.

See Service configuration options to customize container configuration when you build the Docker compose configuration file.

Database container

Container name: db
Docker base image: mariadb, MySQL
Ports exposed: 3306

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:

  • magento-db: /var/lib/mysql
  • .docker/mysql/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d

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 .sh, .sql, and .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.cnf file to the services section in the docker-compose.override.yml file:

    1
    2
    3
    
      db:
        volumes:
          - path/to/custom.my.cnf:/etc/mysql/conf.d/custom.my.cnf
    
  • Add a custom custom.cnf file to the .docker/mysql/mariadb.conf.d directory:

    1
    
    cp custom.cnf .docker/mysql/mariadb.conf.d
    
  • Add configuration values directly to the docker-compose.override.yml file:

    1
    2
    3
    4
    
    services:
      db:
        environment:
          - innodb-buffer-pool-size=134217728
    

See Manage the database for details about using the database.

Elasticsearch container

Container name: elasticsearch
Docker base image: magento/magento-cloud-docker-elasticsearch
Ports exposed: 9200, 9300

The Elasticsearch container for Cloud Docker for Commerce is a standard Elasticsearch container with required plugins and configurations for Adobe Commerce.

Use the --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 Adobe Commerce 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.

Elasticsearch plugins

The analysis-icu and 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-stempel and analysis-nori plugins to the Docker environment.

1
2
3
4
services:
    elasticsearch:
        environment:
          - 'ES_PLUGINS=analysis-stempel analysis-nori'

Troubleshooting

On some Linux systems, when you launch the Docker environment, the Elasticsearch service fails to start and the following error displays:

1
2
ERROR: [1] bootstrap checks failed
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

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 vm.max_map_count:

  1. Edit the sysctl configuration file (etc/sysctl.conf) and set the required value for the vm.max_map_count option.

  2. Reboot your system.

  3. Run the following command to verify the change.

    1
    
    sysctl vm.max_map_count
    

FPM container

Container name: fpm
Docker base image: magento/magento-cloud-docker-php, which is based on the php Docker image
Ports exposed: 9000, 9001

The FPM container includes the following volumes:

  • Read-only volumes:
    • /app
    • /app/vendor
    • /app/generated
    • /app/setup
  • Read/Write volumes:
    • /app/var
    • /app/app/etc
    • /app/pub/static
    • /app/pub/media

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 Adobe Commerce project.

The Cloud Docker deploy process copies the php.ini file to the Docker environment after applying the default Docker and extension configurations and applies the settings to the FPM and CLI containers.

If you use the mutagen file synchronization tools, 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 Adobe Commerce on cloud infrastructure 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.

MailHog container

Container name: mailhog
Docker base image: mailhog
Ports: SMTP:1025, HTTP:8025

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-http-port and --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

RabbitMQ container

Container name: rabbitmq
Docker base image: rabbitmq
Ports exposed: 4369, 5671, 5672, 25672

The RabbitMQ container for Cloud Docker for Commerce is a standard RabbitMQ container with no configuration or changes.

Redis container

Container name: redis
Docker base image: redis
Ports exposed: 6379

The Redis container for Cloud Docker for Commerce 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

Selenium container

Container name: selenium
Docker base image: selenium/standalone-chrome/, based on the selenium/standalone-chrome/ Docker image
Ports exposed: 4444

The Selenium container enables the Magento Functional Testing Framework (MFTF) for application testing in the Cloud Docker environment. See Magento application testing.

Test container

Container name: test
Docker base image: magento/magento-cloud-docker-php, based on the magento/magento-cloud-docker-php Docker image
Ports exposed: None

The Test container, based on the magento/magento-cloud-docker-php Docker image, has a writable file system and is used for application testing in the Cloud Docker environment. See Magento application testing.

TLS container

Container name: tls
Docker base image: magento/magento-cloud-docker-nginx:1.19-1.2.0
Ports: 443 (default), 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 443.
  • If you have Varnish installed in the Docker environment, use port 8080:80 to bypass caching.
  • You can change the default port when you generate the Docker configuration file:

    1
    
    ./vendor/bin/ece-docker build:compose --tls-port <port-number>
    

To increase the timeout on this container, add the following code to the docker-compose.override.yml file:

1
2
3
  tls:
    environment:
      - TIMEOUT=600

Varnish container

Container name: varnish
Docker base image: magento/magento-cloud-docker-varnish, based on the centos Docker image

The Varnish container simulates Fastly and is useful for testing VCL snippets.

The Varnish service is installed by default. When deployment completes, Adobe Commerce is configured to use Varnish for full page caching (FPC) for Adobe Commerce 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 docker-compose.override.yml file.

To clear the Varnish cache:

1
docker-compose exec varnish varnishadm ban req.url '~' '.'

Web container

Container name: web
Docker base image: magento/magento-cloud-docker-nginx, based on the centos Docker image
Ports exposed: None

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-processes to set the number of worker processes for NGINX. The default is 1.
  • --nginx-worker-connections to set the maximum number of connections that each worker process can handle simultaneously. The default is 1024.

The NGINX configuration for this container is the standard Adobe Commerce 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:

  1. On your local host, create a ./.docker/nginx/etc/ directory.

  2. Copy the nginx.conf and vhost.conf configuration files to the new directory.

  3. In the vhost.conf file, customize the values for variables like !UPLOAD_MAX_FILESIZE!; as needed.

  4. To mount the custom NGINX configuration to the Web container, add the volume configuration to the docker-compose.override.yml file.

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:

  1. To mount the custom index.php file to the Web container, add the volume configuration to the docker-compose.override.yml file.
1
2
3
4
  services:
    web:
      volumes:
        - ./pub/index.php:/app/pub/index.php:ro

Zookeeper container

Container name: Zookeeper
Docker base image: zookeeper/latest/
Ports exposed: 2181

Developers can use Zookeeper to manage locks to prevent the launch of duplicate cron jobs and cron groups for Adobe Commerce and Magento Open Source projects running on servers with multiple nodes.

For Adobe Commerce projects on Adobe cloud infrastructure, lock provider settings are configured automatically during provisioning. See Cloud variables.

For projects hosted on other infrastructure, developers can add the Zookeeper container to the Docker environment and configure the service.

1
./vendor/bin/ece-docker build:compose --php <version> --with-zookeeper

The latest Zookeeper version is installed by default from Docker Hub. You can add the following options to customize the installation:

  • --zookeeper-version – Specify a specific version to install from Docker Hub.
  • --zookeeper-image – Specify the Zookeeper image name to install from a custom image.