Docker services containers

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

See the service version values available for use when launching Docker.

Database container

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

The Database container is based on the mariadb image and includes the following volumes:

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

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. Add the custom values using an included my.cnf file, or add the correct variables directly to the override file as shown in the following examples.

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 configuration values to the docker-compose.override.yml file:

1
2
3
  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.

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

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][Docker override] file. Configuration settings in this file are applied only when you build and deploy to the Docker environment.

For additional information about configuring the php environment, see the XDebug for Docker documentation.

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 redis redis-cli -h redis

Selenium container

Container name: selenium
Docker base image: 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.

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.

1
2
3
varnish:
  environment:
    - VARNISHD_PARAMS="-p default_ttl=3600 -p default_grace=3600 -p feature=+esi_ignore_https -p feature=+esi_disable_xml_check"

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:

  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