How to Set Up Magento 2.4 With Docker

How to Set Up Magento 2.4 With Docker

[Updated: March 17, 2026]

Docker gives Magento developers isolated, reproducible environments that work the same on every machine. No more "works on my laptop" problems.

This guide walks you through setting up Magento 2.4.8 with Docker, from choosing the right tool to a running store in under 15 minutes.

Key Takeaways

  • Docker isolates Magento's full stack (PHP, MySQL/MariaDB, OpenSearch, Redis) in containers that spin up in minutes
  • docker-magento by Mark Shust is the most popular community tool with about 40% adoption among Magento developers
  • Magento 2.4.8 requires PHP 8.3 or 8.4, OpenSearch 2.19 (Elasticsearch is deprecated), and MariaDB 11.4 or MySQL 8.4
  • Docker works for development and testing, but production stores need managed hosting with proper scaling, monitoring, and support

What Is Magento 2 Docker?

Magento 2 Docker = a containerized local development environment that packages Magento with all its dependencies. You get a consistent, portable setup that matches across your entire team.

Perfect for: Magento developers, agencies with multiple projects, teams that need identical environments

Not ideal for: Production deployments, stores with high traffic, non-technical store owners

Docker wraps each service Magento needs (PHP-FPM, Nginx, MySQL, OpenSearch, Redis, RabbitMQ) into separate containers. These containers communicate through a shared network but stay isolated from your host system.

The main advantages:

  • Consistent environments. Every developer runs the same PHP version, database version, and extensions
  • Project isolation. Run Magento 2.4.8 on one project and 2.4.7 on another without conflicts
  • Fast onboarding. New team members clone the repo, run one command, and have a working Magento instance
  • No host pollution. Uninstalling means removing containers. No leftover PHP or MySQL processes

Adobe provides an official Docker package (magento/magento-cloud-docker) designed for Commerce Cloud infrastructure replication. For local Open Source development, community tools offer a better experience.

Docker Tools for Magento 2 Compared

Four main tools exist for running Magento 2 in Docker. Each serves a different workflow.

Tool Adoption Best For Magento 2.4.8 Apple Silicon
docker-magento (Mark Shust) ~40% Most developers, simple setup Yes Yes
Warden ~17% Multi-project teams, advanced routing Yes Yes
DDEV ~19% Teams working across multiple CMSs Yes Yes
Cloud Docker (Adobe) Limited Commerce Cloud environment replication Yes Partial

docker-magento is the recommended choice for most setups. It has over 2,800 GitHub stars, active maintenance, and handles PHP 8.1 through 8.4. The one-liner installation sets up the full stack in under 15 minutes. Check the docker-magento repository for the latest setup instructions.

Warden excels at managing multiple Magento projects on one machine. It uses Traefik for automatic HTTPS and domain-based routing. If you juggle 3+ client projects, Warden saves time.

DDEV is a general-purpose Docker tool that supports Magento alongside WordPress, Laravel, and other frameworks. If your team works across different platforms, DDEV keeps the workflow consistent.

Cloud Docker from Adobe replicates the Commerce Cloud environment. Use it if you deploy to Adobe Commerce Cloud and need local parity. For Open Source or self-hosted setups, the community tools work better.

System Requirements for Magento 2.4.8

Magento 2.4.8 (released April 2025) brought significant changes to the technology stack. Your Docker configuration must match these requirements.

Component Required Version Notes
PHP 8.4 or 8.3 PHP 8.2 no longer supported
MySQL 8.4 Or MariaDB 11.4
MariaDB 11.4 Replaces 10.6 from 2.4.7
OpenSearch 2.19 Required for new installations
Elasticsearch 8.17 Deprecated. Migrate to OpenSearch
Composer 2.9.3+ Composer 1.x not supported
Redis 7.2 Or Valkey 8 (new in 2.4.8)
Valkey 8 Drop-in Redis replacement
RabbitMQ 4.1 For message queues
Nginx 1.26 Web server
Varnish 7.6 Full-page cache

For the complete compatibility matrix across all versions, see the Magento system requirements reference.

Important: Elasticsearch is deprecated in 2.4.8. Adobe recommends migrating all installations to OpenSearch. If your existing setup uses Elasticsearch, plan the migration before upgrading. Check our Elasticsearch migration guide for detailed steps.

Set Up Magento 2.4.8 With docker-magento

The fastest path to a working Magento 2.4.8 Docker environment uses Mark Shust's docker-magento. This walkthrough covers a fresh installation on macOS, Linux, or Windows (WSL2).

Prerequisites

Before starting, install these on your host machine:

  • Docker Desktop 4.30+ (includes Docker Compose v2)
  • Magento Marketplace account with access keys from commercemarketplace.adobe.com
  • 8 GB RAM minimum allocated to Docker (16 GB recommended)

Step 1: Create the Project

Run the one-liner installer that downloads Magento and sets up all Docker services:

curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- magento.test community 2.4.8

This command creates a magento.test directory, downloads Magento 2.4.8 Community Edition via Composer, and configures PHP 8.3, MariaDB 11.4, OpenSearch 2.19, Redis, and RabbitMQ. It also adds magento.test to your /etc/hosts file.

The process takes 10 to 15 minutes depending on your internet speed.

Step 2: Enter Marketplace Credentials

When prompted, enter your Magento Marketplace authentication keys:

  • Username = your public key
  • Password = your private key

These keys authenticate Composer with repo.magento.com to download Magento packages.

Step 3: Access Magento

After installation completes:

  • Storefront: https://magento.test
  • Admin panel: https://magento.test/admin
  • Credentials: Use the username and password shown in the terminal output

Step 4: Install Sample Data (Optional)

Sample data populates your store with test products, categories, and CMS pages:

bin/magento sampledata:deploy
bin/magento setup:upgrade

Step 5: Enable Developer Mode

bin/magento deploy:mode:set developer

Developer mode shows errors in the browser and disables static content caching. Keep this active during development.

Step 6: Verify the Stack

Confirm all services run:

docker compose ps

You should see containers for PHP-FPM, Nginx, MariaDB, OpenSearch, Redis, RabbitMQ, and Mailcatcher.

For installing Magento without Docker, see our Composer installation tutorial.

Apple Silicon and Performance Tips

Apple Silicon (M1 Through M4)

Docker on Apple Silicon runs x86 containers through Rosetta 2 emulation. This works but adds overhead. For better performance:

  1. Enable Rosetta in Docker Desktop. Settings → General → check "Use Rosetta for x86_64/amd64 emulation on Apple Silicon"
  2. Use VirtioFS for file sharing. Settings → General → choose "VirtioFS" (2 to 3x faster than osxfs)
  3. Allocate enough resources. Settings → Resources → set at least 8 GB RAM and 4 CPUs

docker-magento, Warden, and DDEV all support Apple Silicon out of the box. No additional configuration needed.

Performance Optimization

Docker file system performance is the number one bottleneck for Magento development. These settings make a measurable difference:

  • VirtioFS (macOS): Use it. Period. It is 2 to 3x faster than the older osxfs driver
  • OPCache tuning: Set opcache.memory_consumption=512 and opcache.max_accelerated_files=60000 in your PHP container
  • Redis for sessions and cache: Never use file-based sessions or cache in Docker. Redis eliminates the file I/O bottleneck
  • Disable Xdebug when not debugging. Xdebug adds 30 to 50% overhead to every PHP request. docker-magento includes a toggle: bin/xdebug disable

Common Docker Errors and Fixes

Error Cause Fix
port 80 already in use Another service occupies port 80 Stop Apache/Nginx on host: sudo apachectl stop or change ports in docker-compose.yml
Elasticsearch connection refused Missing or misconfigured search engine Switch to OpenSearch 2.19 in your Docker config. Magento 2.4.8 deprecates Elasticsearch
SQLSTATE[HY000] [2002] Database container not ready Wait 30 seconds after docker compose up, then retry. Check logs: docker compose logs db
Composer auth required Missing marketplace credentials Create auth.json in project root with your public/private keys
Permission denied on var/ File ownership mismatch Run bin/fixowns (docker-magento) or set proper ownership on var/, generated/, pub/static/
Out of memory Docker has too little RAM Increase Docker Desktop memory to 8 GB+ in Settings → Resources

Development vs Production: When Docker Falls Short

Docker gives developers a fast, consistent local environment. It does not replace proper production infrastructure.

Production Magento stores need:

  • Auto-scaling to handle traffic spikes during sales or campaigns
  • CDN integration for global page load performance
  • Automated backups with point-in-time recovery
  • 24/7 monitoring with alerting for downtime, slow queries, and resource exhaustion
  • Security hardening including WAF, DDoS protection, and patch management

Running Docker in production introduces complexity around orchestration, persistent storage, SSL termination, and container health checks that most teams underestimate.

For production Magento deployments, managed Magento hosting handles the infrastructure so your team focuses on building the store. A proper staging environment guide bridges the gap between your Docker development setup and production.

FAQ

What Docker tool is best for Magento 2 local development?

docker-magento by Mark Shust is the most popular choice with about 40% adoption among Magento developers. It provides a one-command setup, supports PHP 8.1 through 8.4, and includes helpers for common tasks like cache clearing and Xdebug toggling.

Does Magento 2.4.8 still support Elasticsearch?

Elasticsearch 8.17 still works with Magento 2.4.8 but is deprecated. Adobe recommends migrating all installations to OpenSearch 2.19. Future Magento releases will drop Elasticsearch support entirely.

How much RAM does Docker need for Magento 2?

Allocate at least 8 GB of RAM to Docker Desktop. 16 GB provides a smoother experience, especial when running OpenSearch and Redis alongside Magento. Your host machine should have 16 to 32 GB total.

Can I run Magento 2 Docker on Apple Silicon Macs?

Yes. Docker Desktop supports Apple Silicon through Rosetta 2 emulation. Enable VirtioFS file sharing in Docker Desktop settings for better performance. docker-magento, Warden, and DDEV all run on M1, M2, M3, and M4 chips.

What is the difference between docker-magento and Adobe Cloud Docker?

docker-magento is a community-maintained tool for local Magento development on any hosting setup. Adobe Cloud Docker (magento/magento-cloud-docker) replicates the Commerce Cloud infrastructure and is designed for teams deploying to Adobe Commerce Cloud.

How do I set up Xdebug with Magento 2 Docker?

docker-magento includes built-in Xdebug support. Enable it with bin/xdebug enable. For PhpStorm, set the IDE key to PHPSTORM and configure the remote debug server to map /var/www/html to your local project path. For VS Code, use the PHP Debug extension with pathMappings in launch.json.

Is Docker suitable for production Magento stores?

Docker works for development and CI/CD pipelines. For production, most Magento stores run on managed hosting or cloud infrastructure with auto-scaling, CDN, and monitoring. Docker in production requires Kubernetes or Docker Swarm orchestration, which adds significant operational complexity.

What is Valkey and should I use it instead of Redis?

Valkey 8 is a Redis fork supported in Magento 2.4.8 as a drop-in replacement. It is API-compatible with Redis 7.2. You can use either one. Valkey exists because Redis changed its license in 2024. Both work the same way for Magento cache and session storage.

How do I update an existing Docker setup to Magento 2.4.8?

Update the Magento version in composer.json, switch from Elasticsearch to OpenSearch in docker-compose.yml, update PHP to 8.3 or 8.4, and update MariaDB to 11.4. Then run composer update, bin/magento setup:upgrade, and reindex.

What Composer version does Magento 2.4.8 require?

Magento 2.4.8 requires Composer 2.9.3 or higher. Composer 1.x is not supported. docker-magento bundles the correct Composer version in its PHP container, so no manual Composer installation is needed.

CEO & Co-Founder

Raphael Thiel co-founded MGT-Commerce in 2011 together with Stefan Wieczorek and has built it into a leading Magento hosting provider serving 5,000+ customers on AWS. With 25+ years in e-commerce and cloud infrastructure, he oversees hosting architecture for enterprise clients. He also co-founded CloudPanel, an open-source server management platform.


Get the fastest Magento Hosting! Get Started