docker.recipes

WooCommerce E-commerce Stack

intermediate

WordPress WooCommerce with MySQL and Redis.

Overview

WordPress powers over 40% of websites globally, serving as the world's most popular content management system with an ecosystem of 60,000+ plugins and thousands of themes. WooCommerce extends WordPress into a full-featured e-commerce platform, handling everything from product catalogs and inventory management to payment processing and order fulfillment. This stack combines WordPress and WooCommerce with MySQL for reliable data storage, Redis for high-performance caching and session management, and Nginx as a reverse proxy to handle HTTP requests efficiently. MySQL provides ACID-compliant transactions essential for e-commerce operations, while Redis delivers sub-millisecond response times for cart data and user sessions. Nginx's event-driven architecture serves static assets like product images while proxying dynamic requests to WordPress, creating a robust foundation for online stores. This combination is ideal for e-commerce businesses seeking a proven, scalable platform with extensive customization options. Startups can leverage WooCommerce's free core with premium extensions as they grow, while established retailers benefit from the vast ecosystem of themes, payment gateways, and marketing tools. The stack supports everything from digital downloads to complex physical product catalogs with variations, making it suitable for businesses ranging from artisan shops to enterprise retailers processing thousands of orders daily.

Key Features

  • WooCommerce plugin ecosystem with 400+ official extensions for payments, shipping, and marketing
  • WordPress Gutenberg block editor with WooCommerce product blocks for visual store building
  • MySQL InnoDB storage engine with ACID compliance for transaction integrity
  • Redis object caching for WordPress database queries and WooCommerce cart persistence
  • Nginx FastCGI caching with WordPress-specific rules for dynamic content optimization
  • WordPress REST API and WooCommerce API for headless commerce implementations
  • MySQL full-text search capabilities for product catalog indexing
  • Redis session storage for improved checkout performance and user experience

Common Use Cases

  • 1Small to medium online retailers selling physical products with inventory management
  • 2Digital product marketplaces offering downloads, courses, or subscription services
  • 3Multi-vendor marketplaces using WooCommerce marketplace extensions
  • 4B2B wholesale stores with tiered pricing and customer-specific catalogs
  • 5Dropshipping businesses integrating with suppliers and fulfillment services
  • 6Subscription-based businesses selling recurring products or memberships
  • 7Local businesses expanding online with pickup/delivery options and local payment methods

Prerequisites

  • Minimum 2GB RAM (MySQL 1GB, WordPress 512MB, Redis 256MB, Nginx 256MB)
  • Available ports 80 and 443 for HTTP/HTTPS traffic
  • Understanding of WordPress administration and plugin management
  • Basic knowledge of WooCommerce store configuration and product setup
  • SSL certificate for secure payment processing (Let's Encrypt recommended)
  • Familiarity with payment gateway APIs (Stripe, PayPal, etc.) for transaction processing

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 wordpress:
3 image: wordpress:latest
4 container_name: woocommerce
5 restart: unless-stopped
6 environment:
7 - WORDPRESS_DB_HOST=woo-mysql
8 - WORDPRESS_DB_USER=${DB_USER}
9 - WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
10 - WORDPRESS_DB_NAME=woocommerce
11 volumes:
12 - wordpress_data:/var/www/html
13 depends_on:
14 - woo-mysql
15 - woo-redis
16
17 woo-mysql:
18 image: mysql:8.0
19 container_name: woo-mysql
20 restart: unless-stopped
21 environment:
22 - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
23 - MYSQL_DATABASE=woocommerce
24 - MYSQL_USER=${DB_USER}
25 - MYSQL_PASSWORD=${DB_PASSWORD}
26 volumes:
27 - mysql_data:/var/lib/mysql
28
29 woo-redis:
30 image: redis:7-alpine
31 container_name: woo-redis
32 restart: unless-stopped
33 volumes:
34 - redis_data:/data
35
36 nginx:
37 image: nginx:alpine
38 container_name: woo-nginx
39 restart: unless-stopped
40 ports:
41 - "${NGINX_PORT:-80}:80"
42 - "${NGINX_SSL_PORT:-443}:443"
43 volumes:
44 - ./nginx.conf:/etc/nginx/nginx.conf:ro
45 - wordpress_data:/var/www/html:ro
46 depends_on:
47 - wordpress
48
49volumes:
50 wordpress_data:
51 mysql_data:
52 redis_data:

.env Template

.env
1# WooCommerce
2NGINX_PORT=80
3NGINX_SSL_PORT=443
4DB_USER=woocommerce
5DB_PASSWORD=woo_password
6DB_ROOT_PASSWORD=root_password

Usage Notes

  1. 1Docs: https://woocommerce.com/documentation/
  2. 2WooCommerce at http://localhost through Nginx reverse proxy
  3. 3Complete WordPress setup wizard, then install WooCommerce plugin
  4. 4Redis Object Cache plugin for performance (connect to woo-redis:6379)
  5. 5Configure payment gateways: Stripe, PayPal, bank transfer
  6. 6SSL recommended - use Let's Encrypt with certbot

Individual Services(4 services)

Copy individual services to mix and match with your existing compose files.

wordpress
wordpress:
  image: wordpress:latest
  container_name: woocommerce
  restart: unless-stopped
  environment:
    - WORDPRESS_DB_HOST=woo-mysql
    - WORDPRESS_DB_USER=${DB_USER}
    - WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
    - WORDPRESS_DB_NAME=woocommerce
  volumes:
    - wordpress_data:/var/www/html
  depends_on:
    - woo-mysql
    - woo-redis
woo-mysql
woo-mysql:
  image: mysql:8.0
  container_name: woo-mysql
  restart: unless-stopped
  environment:
    - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
    - MYSQL_DATABASE=woocommerce
    - MYSQL_USER=${DB_USER}
    - MYSQL_PASSWORD=${DB_PASSWORD}
  volumes:
    - mysql_data:/var/lib/mysql
woo-redis
woo-redis:
  image: redis:7-alpine
  container_name: woo-redis
  restart: unless-stopped
  volumes:
    - redis_data:/data
nginx
nginx:
  image: nginx:alpine
  container_name: woo-nginx
  restart: unless-stopped
  ports:
    - ${NGINX_PORT:-80}:80
    - ${NGINX_SSL_PORT:-443}:443
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
    - wordpress_data:/var/www/html:ro
  depends_on:
    - wordpress

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 wordpress:
5 image: wordpress:latest
6 container_name: woocommerce
7 restart: unless-stopped
8 environment:
9 - WORDPRESS_DB_HOST=woo-mysql
10 - WORDPRESS_DB_USER=${DB_USER}
11 - WORDPRESS_DB_PASSWORD=${DB_PASSWORD}
12 - WORDPRESS_DB_NAME=woocommerce
13 volumes:
14 - wordpress_data:/var/www/html
15 depends_on:
16 - woo-mysql
17 - woo-redis
18
19 woo-mysql:
20 image: mysql:8.0
21 container_name: woo-mysql
22 restart: unless-stopped
23 environment:
24 - MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
25 - MYSQL_DATABASE=woocommerce
26 - MYSQL_USER=${DB_USER}
27 - MYSQL_PASSWORD=${DB_PASSWORD}
28 volumes:
29 - mysql_data:/var/lib/mysql
30
31 woo-redis:
32 image: redis:7-alpine
33 container_name: woo-redis
34 restart: unless-stopped
35 volumes:
36 - redis_data:/data
37
38 nginx:
39 image: nginx:alpine
40 container_name: woo-nginx
41 restart: unless-stopped
42 ports:
43 - "${NGINX_PORT:-80}:80"
44 - "${NGINX_SSL_PORT:-443}:443"
45 volumes:
46 - ./nginx.conf:/etc/nginx/nginx.conf:ro
47 - wordpress_data:/var/www/html:ro
48 depends_on:
49 - wordpress
50
51volumes:
52 wordpress_data:
53 mysql_data:
54 redis_data:
55EOF
56
57# 2. Create the .env file
58cat > .env << 'EOF'
59# WooCommerce
60NGINX_PORT=80
61NGINX_SSL_PORT=443
62DB_USER=woocommerce
63DB_PASSWORD=woo_password
64DB_ROOT_PASSWORD=root_password
65EOF
66
67# 3. Start the services
68docker compose up -d
69
70# 4. View logs
71docker compose logs -f

One-Liner

Run this command to download and set up the recipe in one step:

terminal
1curl -fsSL https://docker.recipes/api/recipes/woocommerce-stack/run | bash

Troubleshooting

  • WordPress database connection error: Verify WORDPRESS_DB_HOST points to 'woo-mysql' and database credentials match MYSQL_USER/MYSQL_PASSWORD
  • WooCommerce checkout timeouts: Install Redis Object Cache plugin and configure it to connect to 'woo-redis:6379' for session persistence
  • MySQL max_connections exceeded: Add 'max_connections=200' to MySQL environment variables or custom configuration file
  • Nginx 502 Bad Gateway errors: Check that WordPress container is healthy and PHP-FPM is responding on port 9000
  • WooCommerce product images not loading: Ensure wordpress_data volume is mounted to both WordPress and Nginx containers with proper permissions
  • Redis memory usage warnings: Configure Redis maxmemory policy with 'maxmemory-policy allkeys-lru' for cache eviction

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

Ad Space