Local development

Cloud Docker for Commerce is the recommended tool for effective local development and testing of Adobe Commerce.

Prerequisites include the following software:

Docker settings

Cloud Docker for Commerce requires the following Docker resources to support local Docker development. You can allot these resources from the Preferences panel in Docker Desktop. Click the Settings icon next to your username, then choose the Resources tab.

Commerce credentials

Before setting up a local workspace, gather the following credentials and account information:

PHP and Composer

Cloud Docker for Commerce does not require PHP and Composer to be installed locally. Adobe provides an installation script to perform PHP and Composer operations.

The init-docker.sh script runs the following command, which installs the template dependencies and sets both the PHP version and the Cloud Docker for Commerce image version.

docker run --rm -e "MAGENTO_ROOT=/app" -v "$(pwd)":/app -v ~/.composer/cache:/root/.composer/cache "magento/magento-cloud-docker-php:${PHP_VERSION}-cli-${IMAGE_VERSION}" composer install --ansi

The script option settings determine the PHP version and Cloud Docker for Commerce image version. The script also adds the default hostname, magento2.docker, to your /etc/hosts file.

The following table lists the available options to use with the init-docker.sh script:

Option
Description
-p, --php
PHP version (for installing dependencies). Specify a PHP version that is compatible with the Adobe Commerce version deployed to the Cloud Docker environment.
-i, --image
Cloud Docker for Commerce image version (for installing dependencies).<br/>Default: 1.1
--host
Domain name to add to the /etc/hosts file.<br/>Default: magento2.docker
--add-host
Add domain name to /etc/hosts file.<br/>Default: true (yes)

Examples

To run the script with default settings:

bin/init-docker.sh

To install PHP 8.1 and skip adding the domain to the etc/hosts file:

bin/init-docker.sh --php 8.1 --add-host no

On initial project installation, you can use cURL to run the installation script and install the template dependencies. See Update the hosts file and install dependencies.

Web server configuration

Cloud Docker for Commerce binds to port 80 on your host environment. Because macOS provides built-in Apache service, and may occupy port 80, you must stop the service. Also, if you have a web server enabled on your workstation, you must stop the service before launching the Docker environment.

sudo apachectl stop
data-variant=error
data-slots=text
If you start your Docker environment with Apache running, the following error displays: Cannot start service tls: Ports are not available: port is already allocated

<!--Link definitions-->