Blazing fast Magento docker

Blazing fast Magento docker

Slow Magento docker

Frustrated by how incredibly slow Magento 2 docker? Small PHP application works fine with Docker for Mac but not for Magento 2. The entire Magento filesystem is extremely slow with Docker's local development.

Fast Magento 2 docker solution

To improve Docker filesystem mounting performance and speed up Magento 2 development, definitely worth a try a Mark Shust well tuning Magento 2 fast docker solution Nginx

Install Magento 2 docker local development

Step by step:

  • Install and run Docker Desktop on Mac
  • create a folder in your PC and enter to it with the terminal (OS X's command line)
  • Run docker info to confirm Docker up and running
    osx docker up
  • stop any of the local servers like XAMPP, MAMP, WampServer. Avoid ports conflicts MySQL, NGINX or Apache needs to use, ports 443 and 80, are already being used by another application.
  • make sure you do not have magento2.test in the host file. Remove if it has any.

Mac host file

in terminal type

  • sudo nano /etc/hosts
    and then hit return.
  • Enter your administrator password and then hit return.
  • in Nano text editor move the cursor using the arrow keys and position it after the text in the window. Then, remove magento2.test or other local URLs pointing to except the required by docker      localhost kubernetes.docker.internal

    mac host file
  • Once you're done, hold down the control and O keys to save the file, then control and X to exit.

Start Magento docker installation

  • Run this automated one-liner from the directory you want to install your project to
    curl -s | bash -s -- magento2.test with-samples-2.4.1
    or for older Magento versions
    curl -s | bash -s -- magento2.test with-samples-2.3.5-p1
    curl -s | bash -s -- magento2.test 2.3.3
  • the magento2.test above defines the local development hostname to use, and 2.4.1 defines the Magento version to install with the sample data. Thanks Mark Shust for maintaining and updating this docker.
  • the installer will ask for access to repo.magento to enter your Magento repo username and password. Get your magento authentication keys if you don't have one
  • After the one-liner above completes running, you should be able to access your site at https://magento2.test/admin
    How to find Magento 2 admin url




Magento docker tips and tricks

Tip 1: Restart containers

Restart Magento docker by


Command start all containers, better practice to use this instead of docker-compose up -d
docker magento restart


Tip 2: enable Magento 2 debug mode

  • open
    docker compose dev
  • uncomment src/var
    docker magento debug mode
  • Restart Magento docker containers
  • enable Magento 2 development mode
    bin/magento deploy:mode:set developer
  • enable Magento 2 debug mode
    bin/magento setup:config:set --enable-debug-logging=true
  • flush Magento 2 cache
    bin/magento cache:flush


Tip 3: find Magento 2 admin URL

bin/magento info:adminuri

magento find Magneto admin


Tip 4: add a new Magento 2 administrator

bin/magento admin:user:create --admin-user=“user2” --admin-password=“2534pasworD” --admin-email="" --admin-firstname="Admin" --admin-lastname="Admin"

magento create new admin


Tip 5: Magento 2 sample data

  • run
    bin/magento sampledata:deploy
  • sample data modules installed but not enabled
    bin/magento module:status
  • enable Magento 2 sample data modules
    bin/magento module:enable Magento_CustomerSampleData Magento_MsrpSampleData Magento_CatalogSampleData Magento_DownloadableSampleData Magento_OfflineShippingSampleData Magento_BundleSampleData Magento_ConfigurableSampleData Magento_ThemeSampleData Magento_ProductLinksSampleData Magento_ReviewSampleData Magento_CatalogRuleSampleData Magento_SwatchesSampleData Magento_GroupedProductSampleData Magento_TaxSampleData Magento_CmsSampleData Magento_SalesRuleSampleData Magento_SalesSampleData Magento_WidgetSampleData Magento_WishlistSampleData/pre>
  • Run setup and flush the cache
    bin/magento setup:upgrade
    bin/magento setup:di:compile
    bin/magento indexer:reindex
    bin/magento setup:static-content:deploy


Tip 6: Failed to start docker for missing volume files

To resolve the "Failed to start docker for missing volume files"

  • resolve permissions errors. You may or not see the
    ./src/app/design: No such file or directory
    ./src/composer.lock: No such file or directory
    errors in the terminal. Those are required by the /magento/ file and if OS does not allow the installer to create these directories and files in the folder where you start the Magento you required to create them manually.
  • open docker dashboard
  • find your Magento docker and click the start button
  • after a moment check is all containers started
  • if the server started but return 403 Forbidden error check your host file and add if missing the ::1 magento2.test

Tip 7: Connect to Magento docker database with phpmyadmin

Add phpmyadmin service to the docker-compose.yml

    image: rabbitmq:3.7-management
      - "15672:15672"
      - "5672:5672"
      - rabbitmqdata:/var/lib/rabbitmq

    image: phpmyadmin/phpmyadmin
      - 8336:80
      PMA_HOST: db
      PMA_USER: magento
      PMA_PASSWORD: magento

Restart the containers with bin/restart

View your magento docker database in browser http://magento2.test:8336

  • user


    Dear If you set the magento version to previous than 2.4, the php version isn't compatible because it requires a max 7.3. So composer fails to update. Any way to set php 7.3 ? Regards

    3 years ago