Docker services containers
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.
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 theservices
section in thedocker-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 Magento Cloud Docker is a standard Elasticsearch container with required plugins and configurations for Magento 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 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
.
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
:
-
Edit the sysctl configuration file (
etc/sysctl.conf
) and set the required value for thevm.max_map_count
option. -
Reboot your system.
-
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 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 docker-sync
or 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.
RabbitMQ container
Container name: rabbitmq
Docker base image: rabbitmq
Ports exposed: 4369
, 5671
, 5672
, 25672
The RabbitMQ container for Magento Cloud Docker 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 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
Selenium container
Container name: selenium
Docker base image: [selenium/standalone-chrome/](https://hub.docker.com/r/selenium/standalone-chrome
Ports exposed: 4444
The Selenium container, based on the selenium/standalone-chrome/, enables the Magento Functional Testing Framework (MFTF) for Magento application testing in the Cloud Docker environment. See Magento application testing.
TLS container
Container name: tls
Docker base image: magento/magento-cloud-docker-tls, which is based on the debian:jessie Docker image
Ports exposed: 443
</br>
The TLS termination proxy container facilitates the Varnish SSL termination over HTTPS.
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, which is based on the centos
Ports exposed: 80
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 7.2 --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, which is 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.
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
./.docker/nginx/etc/
directory. -
Copy the
nginx.conf
andvhost.conf
configuration files to the new directory. -
In the
vhost.conf
file, customize the values for variables like!UPLOAD_MAX_FILESIZE!;
as needed. -
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:
- 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