Docker development quick reference
See Configure Docker for additional information about Docker prerequisites and using the Magento Cloud Docker environment.
Docker Compose
Action | Command |
---|---|
Build and start Docker environment | docker-compose up -d |
Build environment | docker-compose run --rm build cloud-build |
Deploy environment | docker-compose run --rm deploy cloud-deploy |
Run post-deploy hooks | docker-compose run --rm deploy cloud-post-deploy |
Connect to CLI container | docker-compose run --rm deploy bash |
Use ece-tools command |
docker-compose run --rm deploy ece-command <command> |
Use Magento command | docker-compose run --rm deploy magento-command <command> |
Stop and remove Docker environment (removes volumes) | docker-compose down -v |
Stop Docker environment without destroying containers | docker-compose stop |
Resume Docker environment | docker-compose start |
List images | docker-compose images |
List containers and ports | docker-compose ps or docker ps |
The --rm
option automatically removes containers when they stop. This setting overrides any restart policy specified in the service configuration and prevents orphaned containers from consuming excess disk space. See docker-compose run
in the Docker command-line reference.
Override configuration
Because the ece-docker build:compose
command overwrites the base configuration, we recommend saving your customizations in an override configuration file. You can use this method to merge multiple custom configurations. See Docker Docs: Multiple Compose files.
The docker-compose up
command considers the base docker-compose.yml
configuration by default. If the docker-compose.override.yml
file is present, then the override configuration merges with the base configuration.
Use the -f
argument to specify an alternate configuration file. The following example uses the default configuration and merges each custom configuration sequentially:
1
docker-compose -f docker-compose.yml -f docker-compose-custom.yml [-f more-custom-docker-compose.yml] up
Docker Compose configuration generator
You use the following commands to generate the Docker configuration files and build your environment.
Action | Command |
---|---|
Builds the Docker environment in production mode by default and verifies configured service versions. | ece-docker build:compose |
Builds the docker environment in developer mode. | ece-docker build:compose --mode="developer" |
Builds the docker environment in production mode. | ece-docker build:compose --mode="production" |
Convert PHP configuration files to Docker ENV files. | ece-docker image:generate:php |
For example, the following command starts the Docker configuration generator in developer mode and specifies PHP version 7.2:
1
./vendor/bin/ece-docker build:compose --mode="developer" --php 7.2
Use the following command to list the Magento Cloud Docker ece-docker
commands:
1
php ./vendor/bin/ece-docker list
The ece-docker build:compose
command runs in interactive mode and verifies the configured service versions. To skip interactive mode, use the -n, --no-interaction
option.
Additional build options
Option | Key | Available values |
---|---|---|
Mode | --mode , -m |
production, developer |
File synchronization engine | --sync-engine |
native (default), docker-sync, mutagen |
Specify a custom URL for Magento | --host --port |
See Service versions for a list of service configuration options you can add to the ece-docker build:compose
command to customize the Cloud Docker environment configuration.
Magento Cloud Docker CLI
The bin/magento-docker
commands simplify running docker-compose tasks. For example, instead of running a separate docker-compose command for the build, deploy, and post-deploy steps, you can redeploy Magento in a Docker environment using the following command:
1
./bin/magento-docker ece-redeploy
The following example shows the ./bin/magento-docker
command and output when connecting to the bash shell:
1
./bin/magento-docker bash
1
2
3
4
5
Starting project_redis_1 ... done
Starting project_db_1 ... done
Starting project_elasticsearch_1 ... done
[ ok ] Starting enhanced syslogd: rsyslogd.
root@deploy:/app#
Action | Command |
---|---|
Connect to bash shell | ./bin/magento-docker bash |
Pull the latest images | ./bin/magento-docker pull |
Build application | ./bin/magento-docker ece-build |
Deploy application | ./bin/magento-docker ece-deploy |
Run post-deploy hooks | ./bin/magento-docker ece-post-deploy |
Re-build and re-deploy application | ./bin/magento-docker ece-redeploy |
Stop containers | ./bin/magento-docker stop |
Start containers | ./bin/magento-docker start |
Restart containers | ./bin/magento-docker restart |
Destroy containers | ./bin/magento-docker down |
Destroy, re-create, and start containers | ./bin/magento-docker up |