Common DevBox commands

DevBox is currently undergoing an update and is not available for download. A new version will be available in the near future. Please check back for updates.

This topic lists DevBox commands you might find useful for day-to-day use or when troubleshooting issues. For more information about the Docker commands on which many of these are based, see the Docker command reference.

Run cron, populate the cache and the storefront

Populating the cache and storefront causes the storefront, products, and images to load faster. Use this option after you make changes to the product catalog to pre-deploy static assets and put objects in the cache so the storefront loads faster.

You can also start the Magento cron job.

However, enabling these options consumes resources and might drain your battery.

Populate the storefront and cache and run cron (running system)

This section discusses how to populate the cache and storefront, and run cron, on a running DevBox system.

Start the Magento cron job and populate the cache

Use the following command to both start the Magento cron job and populate the cache and storefront:

docker-compose exec --user=magento2 web m2init magento:finalize --magento-warm-up-storefront=1 --magento-cron-run=1 --no-interaction

Start the Magento cron job only

Use the following command on a running system to only start the Magento cron job. This command might save resources and battery life on your laptop.

docker-compose exec --user=magento2 web m2init magento:finalize --magento-cron-run=1 --no-interaction

Populate the storefront and cache only

Use the following command on a running system to only populate the storefront and cache but not run the Magento cron job.

docker-compose exec --user=magento2 web m2init magento:finalize --magento-warm-up-storefront=1 --no-interaction

Configure DevBox to always populate the storefront and cache and run cron

To populate the storefront and cache, and run cron to run every time Magento starts:

  1. Stop all running containers.

    docker-compose stop
    
  2. Open <project root dir>/docker-compose.yml in a text editor.
  3. You have the following options:

    • To enable cron to run only, set the value of the following parameter to 1:

      MAGENTO_CRON_RUN=1
      
    • To only populate the storefront and cache but not run the Magento cron job, set the value of the following parameter to 1:

      MAGENTO_WARM_UP_STOREFRONT=1
      
    • To both enable the Magento cron job and to always populate the storefront and cache, set the values of both of the following parameters to 1:

      MAGENTO_CRON_RUN=1
      MAGENTO_WARM_UP_STOREFRONT=1
      
  4. Save your changes to docker-compose.yml and exit the text editor.
  5. Start all containers.

    docker-compose start
    

Stop, start, restart, and view port mappings

You can use the following commands to start, stop, and restart services; and you can find the ports currently being used by the services.

Run all commands from your DevBox root folder.

Restart the containers after rebooting

After you restart your computer, we recommend you use the following command, which restarts all services and assigns them new ports:

m2devbox-reset[.bat|sh]

Find currently used ports

If you’re not sure what ports on which DevBox services are running, use the docker-compose ps command as follows:

docker-compose ps

                         Name                                        Command               State                                                 Ports                                              
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
magento2devbox_db_709831d587f2feef1e27fa41d4e70219        docker-entrypoint.sh mysqld      Up      0.0.0.0:32780->3306/tcp                                                                          
magento2devbox_elastic_709831d587f2feef1e27fa41d4e70219   /docker-entrypoint.sh elas ...   Up      0.0.0.0:32777->9200/tcp, 9300/tcp                                                                
magento2devbox_rabbit_709831d587f2feef1e27fa41d4e70219    docker-entrypoint.sh rabbi ...   Up      15671/tcp, 0.0.0.0:32778->15672/tcp, 25672/tcp, 4369/tcp, 5671/tcp, 0.0.0.0:32779->5672/tcp      
magento2devbox_redis_709831d587f2feef1e27fa41d4e70219     docker-entrypoint.sh redis ...   Up      6379/tcp                                                                                         
magento2devbox_web_709831d587f2feef1e27fa41d4e70219       /usr/local/bin/entrypoint.sh     Up      22/tcp, 0.0.0.0:22->32705/tcp, 44100/tcp, 0.0.0.0:32781->5000/tcp, 0.0.0.0:32782->80/tcp, 9000/tcp

In the preceding example:

  • The database listens on port 32780
  • Elasticsearch listens on ports 32777 and 9300
  • RabbitMQ listens on ports 15671, 32778, 25672, 4369, 5671, and 32779
  • Redis listens on port 6379
  • In the web container, the following ports are used:

    • SSH listens on port 32705

      Applications like PhpStorm communicate with DevBox on the SSH listen port. It’s very important to know this port.

    • Unison synchronization (Windows only) listens on port 32781
    • The web server listens on port 32782

You can use any unmapped ports anyway you like. (An example of an unmapped port is port 9000 in the web container in the preceding example.)

Start, stop, restart services

DevBox uses two service names: web and db. To start, stop, or restart them, use the following commands:

docker-compose start <service>
docker-compose stop <service>
docker-compose restart <service>

For example, to restart the web service:

docker-compose restart web

General purpose commands

Description Command
List all Magento containers, shows port mappings docker-compose ps
Start a container docker-compose start <service>
Stop a container docker-compose stop <service>
Restart a container docker-compose restart <service>
Restart all containers docker-compose restart
Start all Magento containers docker-compose start
Stop all Magento containers docker-compose stop
Restart all Magento containers docker-compose restart
Remove all Magento containers docker-compose kill
Run a bash shell in a container docker-compose exec --user=magento2 <service> /bin/bash