Container Architecture
The magento-cloud-docker package contains build information to create a Docker environment with the required specifications for Adobe Commerce.
The build configuration creates a Docker instance with CLI and service containers required to preview and test an Adobe Commerce project in a local Docker environment. Cloud Docker for Commerce generates the docker-compose.yml file to the required specifications. Then, use docker compose to create the container instances and build and deploy the Adobe Commerce site.
CLI Containers
The following CLI containers, most of which are based on a PHP-CLI version 7 Docker image, provide magento-cloud and ece-tools commands to perform file system operations and interact with the application:
See CLI containers.
Service containers
Cloud Docker for Commerce references the .magento.app.yaml and .magento/services.yaml configuration files to determine the services you need. When you start the Docker configuration generator using the ece-docker build:compose command, use the optional build parameters to override a default service version or specify custom configuration.
For example, the following command starts the Docker configuration generator in developer mode and specifies PHP version 8.1:
./vendor/bin/ece-docker build:compose --mode="developer" --php 8.1
See Service containers.
Service configuration options
The following table shows the options to customize service container configuration when you generate the Docker Compose configuration file.
--db, --db-image (MySQL)<br/>--expose-db-port<br/>--db-increment<br/>--db-offset<br/>--with-entrypoint<br/>--with-mariadb-config--with-entrypoint and --with-mariadb-config options to automatically configure database directories in the Docker environment<br/><br/>Example build commands:<br/>ece-docker build:compose --db <mariadb-version><br/>ece-docker build:compose --db <mysql-version> --db-image--es<br/>--es-env-var<br/>--no-es--os<br/>--os-env-var<br/>--no-os--php<br/>--with-xdebug--no-mailhog<br/>--mailhog-http-port<br/>--mailhog-smtp-port--node--node option to install a specific node version.--amq--amq option to install a specific ActiveMQ Artemis version.--rmq--rmq option to install a specific RabbitMQ version.--with-selenium<br/>--selenium-version<br/>--selenium-image--tls-port<br/>--no-tls--tls-port option to change the default port (443).<br/>Use the --no-tls option to disable tls.--no-varnish--no-varnish option to skip Varnish service installation.--with-zookeeper<br/>--zookeeper-version<br/>--zookeeper-image--zookeeper-version option to install a specified version of Zookeeper from the Docker Hub or install a specified image by name with the --zookeeper-image option.Use the following command to view all available options for the ece-docker build:compose command:
./vendor/bin/ece-docker build:compose --help
Request Flow
Web requests to https://magento2.docker/ are handled by the Docker containers using the following request flow:
- TLS
- Varnish
- Web (nginx)
- FPM
data-variant=help
data-slots=text
Sharing data between host machine and container
You can share files easily between your machine and a Docker container by placing the files in the .docker/mnt directory. You can find the files in the /mnt directory the next time you build and start the Docker environment using the docker compose up command.
Sharing project data
When you launch the Adobe Commerce on cloud infrastructure project in a local Docker environment, the default project configuration creates the following volumes:
magento-var
magento-app-etc
magento-pub-media
magento-pub-static
You can use these volumes to interact with the shared writeable mount directories for your Adobe Commerce on cloud infrastructure project, which are configured by default in the .magento.app.yaml file.
# The mounts that will be performed when the package is deployed.
mounts:
"var": "shared:files/var"
"app/etc": "shared:files/etc"
"pub/media": "shared:files/media"
"pub/static": "shared:files/static"
You can customize this configuration by updating the mounts section in the magento.app.yaml file.
File synchronization
Also, you can share data into the containers using file synchronization. See the File synchronization and Developer mode documentation.
Container Volumes
Cloud Docker for Commerce uses Docker volumes to maintain data throughout the lifecycle of the Docker containers. These volumes can be defined in several ways:
- Docker Compose files such as
docker-compose.yml - Dockerfile from the magento-cloud-docker repository
- Upstream Docker image
You do not interact with most of these volumes, which are used by the Docker containers and follow the docker-compose lifecycle. The only exception to this is the magento-sync directory that is an external volume used by the Mutagen application to transport data into the containers from the host operating system.
Rebuild a clean environment
The docker compose down command removes all components of your local Docker instance, including containers, networks, volumes, and images. However, this command does not affect the persistent database volume or the magento-sync volume used for file synchronization.
To remove all data and rebuild a clean environment:
bin/magento-docker down -v
The magento-sync volume is an external volume that you must create or delete manually. If the magento-sync volume does not exist, the following error message displays:
ERROR: Volume magento-sync declared as external, but could not be found. Please create the volume manually using `docker volume create --name=magento-sync` and try again.
Container Logs
All containers use the Docker logging method. You can view the logs using the docker-compose command. The following example uses the -f option to follow the log output of the TLS container:
docker compose logs -f tls
Now you can see all requests that are passing through the TLS container and check for errors.
<!-- link definitions -->