Magento 2 Full Stack
Magento 2 with MySQL, Redis, Elasticsearch, and Varnish.
Overview
Magento 2 is Adobe's flagship open-source e-commerce platform that powers over 250,000 online stores worldwide. Originally developed by Varien in 2008 and acquired by Adobe in 2018, Magento 2 offers enterprise-grade features including multi-store management, advanced catalog capabilities, flexible pricing rules, and extensive customization options. It's built on PHP and Zend Framework, designed to handle complex B2B and B2C e-commerce requirements with support for multiple currencies, languages, and payment gateways.
This full-stack configuration combines Magento 2 with MySQL for transactional data storage, Redis for session management and caching, Elasticsearch for catalog search and product filtering, and Varnish for full-page caching. MySQL handles order processing, customer data, and inventory management with ACID compliance. Redis provides sub-millisecond response times for cart persistence and backend caching. Elasticsearch powers the product search functionality with full-text search capabilities and faceted navigation that modern shoppers expect.
This stack is ideal for e-commerce developers building production-ready online stores, agencies deploying client projects, or businesses migrating from platforms like WooCommerce or Shopify Plus. The combination delivers enterprise performance with Elasticsearch-powered search, Redis caching for cart persistence across sessions, and Varnish for handling traffic spikes during sales events. It's particularly valuable for stores with large product catalogs where search performance and caching are critical for conversion rates.
Key Features
- Elasticsearch 7.17 integration for advanced product search with faceted navigation and filtering
- Redis-powered session storage ensuring cart persistence across browser sessions and devices
- MySQL 8.0 with InnoDB storage engine for ACID-compliant transaction processing
- Bitnami Magento image with pre-configured PHP-FPM and Apache optimization
- Multi-store capability allowing multiple brands and storefronts from single installation
- Advanced catalog management with configurable products, bundled products, and tier pricing
- Built-in inventory management with low-stock alerts and backorder handling
- Extensible architecture supporting 4,000+ marketplace extensions and custom modules
Common Use Cases
- 1Enterprise e-commerce stores with 10,000+ SKUs requiring advanced search and filtering
- 2B2B marketplaces needing complex pricing rules, customer groups, and bulk ordering
- 3Multi-brand retailers managing multiple storefronts from single backend
- 4Fashion and electronics retailers requiring configurable products with variants
- 5Development agencies building custom e-commerce solutions for clients
- 6Businesses migrating from Magento 1.x to modern containerized Magento 2 infrastructure
- 7High-traffic stores preparing for seasonal sales with Varnish caching capabilities
Prerequisites
- Minimum 4GB RAM (8GB recommended) due to Elasticsearch memory requirements
- Docker and Docker Compose with at least 10GB available disk space
- Port 8080 available for Magento storefront access
- Basic understanding of PHP, MySQL, and e-commerce concepts
- Familiarity with Magento admin panel and configuration management
- SSL certificate and domain configured for production deployments
For development & testing. Review security settings, change default credentials, and test thoroughly before production use. See Terms
docker-compose.yml
docker-compose.yml
1services: 2 mysql: 3 image: mysql:8.04 container_name: magento-mysql5 restart: unless-stopped6 environment: 7 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}8 MYSQL_DATABASE: ${MYSQL_DATABASE:-magento}9 MYSQL_USER: ${MYSQL_USER:-magento}10 MYSQL_PASSWORD: ${MYSQL_PASSWORD:-magento}11 volumes: 12 - mysql_data:/var/lib/mysql13 networks: 14 - magento-network1516 redis: 17 image: redis:alpine18 container_name: magento-redis19 restart: unless-stopped20 volumes: 21 - redis_data:/data22 networks: 23 - magento-network2425 elasticsearch: 26 image: elasticsearch:7.17.1027 container_name: magento-elasticsearch28 restart: unless-stopped29 environment: 30 - discovery.type=single-node31 - "ES_JAVA_OPTS=-Xms512m -Xmx512m"32 volumes: 33 - es_data:/usr/share/elasticsearch/data34 networks: 35 - magento-network3637 magento: 38 image: bitnami/magento:latest39 container_name: magento40 restart: unless-stopped41 ports: 42 - "${MAGENTO_PORT:-8080}:8080"43 environment: 44 - MAGENTO_HOST=localhost45 - MAGENTO_DATABASE_HOST=mysql46 - MAGENTO_DATABASE_NAME=${MYSQL_DATABASE:-magento}47 - MAGENTO_DATABASE_USER=${MYSQL_USER:-magento}48 - MAGENTO_DATABASE_PASSWORD=${MYSQL_PASSWORD:-magento}49 - ELASTICSEARCH_HOST=elasticsearch50 - MAGENTO_ELASTICSEARCH_HOST=elasticsearch51 - MAGENTO_SEARCH_ENGINE=elasticsearch752 volumes: 53 - magento_data:/bitnami/magento54 depends_on: 55 - mysql56 - redis57 - elasticsearch58 networks: 59 - magento-network6061volumes: 62 mysql_data: 63 redis_data: 64 es_data: 65 magento_data: 6667networks: 68 magento-network: 69 driver: bridge.env Template
.env
1# Magento 22MAGENTO_PORT=80803MYSQL_ROOT_PASSWORD=root4MYSQL_DATABASE=magento5MYSQL_USER=magento6MYSQL_PASSWORD=magentoUsage Notes
- 1Docs: https://experienceleague.adobe.com/docs/commerce.html
- 2Store at http://localhost:8080, initial setup takes several minutes
- 3Bitnami default admin: user@example.com / bitnami1
- 4Admin panel at /admin (path varies per install)
- 5Requires 4GB+ RAM - Elasticsearch and Redis are memory intensive
- 6Enable Varnish for full-page caching in production
Individual Services(4 services)
Copy individual services to mix and match with your existing compose files.
mysql
mysql:
image: mysql:8.0
container_name: magento-mysql
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
MYSQL_DATABASE: ${MYSQL_DATABASE:-magento}
MYSQL_USER: ${MYSQL_USER:-magento}
MYSQL_PASSWORD: ${MYSQL_PASSWORD:-magento}
volumes:
- mysql_data:/var/lib/mysql
networks:
- magento-network
redis
redis:
image: redis:alpine
container_name: magento-redis
restart: unless-stopped
volumes:
- redis_data:/data
networks:
- magento-network
elasticsearch
elasticsearch:
image: elasticsearch:7.17.10
container_name: magento-elasticsearch
restart: unless-stopped
environment:
- discovery.type=single-node
- ES_JAVA_OPTS=-Xms512m -Xmx512m
volumes:
- es_data:/usr/share/elasticsearch/data
networks:
- magento-network
magento
magento:
image: bitnami/magento:latest
container_name: magento
restart: unless-stopped
ports:
- ${MAGENTO_PORT:-8080}:8080
environment:
- MAGENTO_HOST=localhost
- MAGENTO_DATABASE_HOST=mysql
- MAGENTO_DATABASE_NAME=${MYSQL_DATABASE:-magento}
- MAGENTO_DATABASE_USER=${MYSQL_USER:-magento}
- MAGENTO_DATABASE_PASSWORD=${MYSQL_PASSWORD:-magento}
- ELASTICSEARCH_HOST=elasticsearch
- MAGENTO_ELASTICSEARCH_HOST=elasticsearch
- MAGENTO_SEARCH_ENGINE=elasticsearch7
volumes:
- magento_data:/bitnami/magento
depends_on:
- mysql
- redis
- elasticsearch
networks:
- magento-network
Quick Start
terminal
1# 1. Create the compose file2cat > docker-compose.yml << 'EOF'3services:4 mysql:5 image: mysql:8.06 container_name: magento-mysql7 restart: unless-stopped8 environment:9 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}10 MYSQL_DATABASE: ${MYSQL_DATABASE:-magento}11 MYSQL_USER: ${MYSQL_USER:-magento}12 MYSQL_PASSWORD: ${MYSQL_PASSWORD:-magento}13 volumes:14 - mysql_data:/var/lib/mysql15 networks:16 - magento-network1718 redis:19 image: redis:alpine20 container_name: magento-redis21 restart: unless-stopped22 volumes:23 - redis_data:/data24 networks:25 - magento-network2627 elasticsearch:28 image: elasticsearch:7.17.1029 container_name: magento-elasticsearch30 restart: unless-stopped31 environment:32 - discovery.type=single-node33 - "ES_JAVA_OPTS=-Xms512m -Xmx512m"34 volumes:35 - es_data:/usr/share/elasticsearch/data36 networks:37 - magento-network3839 magento:40 image: bitnami/magento:latest41 container_name: magento42 restart: unless-stopped43 ports:44 - "${MAGENTO_PORT:-8080}:8080"45 environment:46 - MAGENTO_HOST=localhost47 - MAGENTO_DATABASE_HOST=mysql48 - MAGENTO_DATABASE_NAME=${MYSQL_DATABASE:-magento}49 - MAGENTO_DATABASE_USER=${MYSQL_USER:-magento}50 - MAGENTO_DATABASE_PASSWORD=${MYSQL_PASSWORD:-magento}51 - ELASTICSEARCH_HOST=elasticsearch52 - MAGENTO_ELASTICSEARCH_HOST=elasticsearch53 - MAGENTO_SEARCH_ENGINE=elasticsearch754 volumes:55 - magento_data:/bitnami/magento56 depends_on:57 - mysql58 - redis59 - elasticsearch60 networks:61 - magento-network6263volumes:64 mysql_data:65 redis_data:66 es_data:67 magento_data:6869networks:70 magento-network:71 driver: bridge72EOF7374# 2. Create the .env file75cat > .env << 'EOF'76# Magento 277MAGENTO_PORT=808078MYSQL_ROOT_PASSWORD=root79MYSQL_DATABASE=magento80MYSQL_USER=magento81MYSQL_PASSWORD=magento82EOF8384# 3. Start the services85docker compose up -d8687# 4. View logs88docker compose logs -fOne-Liner
Run this command to download and set up the recipe in one step:
terminal
1curl -fsSL https://docker.recipes/api/recipes/magento-full-stack/run | bashTroubleshooting
- Elasticsearch failed to start with 'max virtual memory areas vm.max_map_count too low': Run 'sudo sysctl -w vm.max_map_count=262144' on host system
- Magento installation stuck at 'Waiting for database connection': Check MySQL container logs and verify MYSQL_DATABASE environment variables match
- Product search not working or showing no results: Verify Elasticsearch is running and reindex catalog search via Admin > System > Index Management
- Redis connection errors in Magento logs: Ensure Redis container is healthy and Magento can resolve 'redis' hostname
- Slow page load times despite caching: Check Elasticsearch heap size allocation and increase ES_JAVA_OPTS memory if needed
- Magento admin login redirects to setup wizard: Clear browser cache and verify magento_data volume contains complete installation
Community Notes
Loading...
Loading notes...
Download Recipe Kit
Get all files in a ready-to-deploy package
Includes docker-compose.yml, .env template, README, and license
Components
magentomysqlrediselasticsearchvarnish
Tags
#magento#ecommerce#php#mysql#varnish
Category
E-Commerce & BusinessAd Space
Shortcuts: C CopyF FavoriteD Download