# Shopware

> Open-source headless commerce platform.

- Category: E-Commerce & Business
- Difficulty: advanced
- Components: shopware, mysql, elasticsearch
- Tags: shopware, php, headless, enterprise
- Source: https://docker.recipes/ecommerce/shopware

## Overview

Shopware is a modern, German-born e-commerce platform that has evolved from a traditional monolithic system into a powerful headless commerce solution. Built with PHP and Symfony, Shopware provides both traditional storefront capabilities and headless API-first architecture, making it particularly attractive for enterprise retailers who need flexibility in their frontend implementations. The platform emphasizes developer experience with its plugin system, comprehensive APIs, and modern architecture patterns. This Docker stack combines Shopware's production-ready container with MySQL 8.0 for transactional data storage and Elasticsearch 7.17 for advanced search capabilities. MySQL handles all product catalogs, customer data, orders, and configuration while Elasticsearch powers the sophisticated product search, filtering, and recommendation features that modern e-commerce demands. The integration between these components creates a robust foundation where Shopware automatically syncs product data to Elasticsearch for lightning-fast search responses while maintaining data consistency in MySQL. This configuration is ideal for businesses moving from platforms like Magento or WooCommerce who need enterprise-grade performance, developers building custom storefronts using Shopware's Store API, and organizations implementing omnichannel commerce strategies. The headless capabilities combined with Elasticsearch's analytics features make this stack particularly valuable for retailers requiring advanced personalization and search-driven shopping experiences.

## Features

- Shopware Store API and Admin API for complete headless commerce implementation
- MySQL InnoDB storage with ACID compliance for reliable order and inventory management
- Elasticsearch full-text search with relevance scoring for advanced product discovery
- Shopware App System enabling custom plugins and third-party integrations
- Shopware Flow Builder for automated business processes and customer journeys
- Elasticsearch aggregations powering dynamic product filtering and faceted search
- MySQL JSON data type support for flexible product variant and custom field storage
- Shopware Shopping Experiences visual page builder for content management

## Use cases

- Mid-size retailers migrating from Magento seeking better developer experience and performance
- B2B companies needing complex pricing rules, customer groups, and procurement workflows
- Agencies building custom React or Vue.js storefronts using Shopware's headless APIs
- Multi-brand retailers requiring separate storefronts with shared inventory and customer data
- Fashion and electronics retailers needing advanced product search with filters and recommendations
- International businesses requiring multi-language, multi-currency, and multi-domain capabilities
- Marketplace operators building vendor management and commission tracking systems

## Prerequisites

- Minimum 6GB RAM (2GB for Elasticsearch, 1GB for MySQL, 2GB for Shopware, plus system overhead)
- Docker Engine 20.10+ and Docker Compose v2 for proper container orchestration
- Available ports 8080 for Shopware storefront and admin panel access
- Basic understanding of PHP e-commerce platforms and Symfony framework concepts
- Knowledge of MySQL database administration for backup and performance tuning
- Familiarity with Elasticsearch concepts for search optimization and index management

## docker-compose.yml

```yaml
services:
  shopware:
    image: shopware/production:latest
    container_name: shopware
    restart: unless-stopped
    environment:
      DATABASE_URL: mysql://${DB_USER}:${DB_PASSWORD}@mysql:3306/${DB_NAME}
      APP_URL: http://localhost:8080
      ELASTICSEARCH_HOSTS: elasticsearch:9200
    volumes:
      - shopware_data:/var/www/html
    ports:
      - "8080:80"
    depends_on:
      - mysql
      - elasticsearch
    networks:
      - shopware

  mysql:
    image: mysql:8.0
    container_name: shopware-mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
      MYSQL_DATABASE: ${DB_NAME}
      MYSQL_USER: ${DB_USER}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - shopware

  elasticsearch:
    image: elasticsearch:7.17.0
    container_name: shopware-es
    environment:
      - discovery.type=single-node
    volumes:
      - es_data:/usr/share/elasticsearch/data
    networks:
      - shopware

volumes:
  shopware_data:
  mysql_data:
  es_data:

networks:
  shopware:
    driver: bridge
```

## .env

```bash
DB_ROOT_PASSWORD=rootpassword
DB_NAME=shopware
DB_USER=shopware
DB_PASSWORD=changeme
```

## Usage notes

- Docs: https://docs.shopware.com/
- Access storefront at http://localhost:8080, admin at /admin
- Default admin: admin / shopware (change immediately)
- Headless Store API and Admin API for integrations
- App system for plugins, flows for automation
- Enterprise features in commercial editions

## Troubleshooting

- Shopware installation wizard fails: Ensure DATABASE_URL format is exactly mysql://user:password@mysql:3306/database and MySQL is fully started
- Elasticsearch connection refused errors: Verify Elasticsearch container has enough memory and set ES_JAVA_OPTS="-Xms1g -Xmx1g" environment variable
- Product search returns no results: Check Shopware admin under Settings > Extensions > Shopware Search to rebuild Elasticsearch indices
- MySQL connection timeout during setup: Add 'wait_timeout=28800' to MySQL configuration and ensure containers start in correct dependency order
- Shopware admin panel shows 500 errors: Check PHP memory limit in production image and verify all required PHP extensions are loaded
- Elasticsearch cluster health yellow/red: Increase vm.max_map_count on Docker host with 'sysctl -w vm.max_map_count=262144'

