docker.recipes

WooCommerce Complete E-commerce

intermediate

WordPress WooCommerce with payment gateways, caching, and search.

Overview

WordPress is the world's most popular content management system, powering over 40% of all websites. Originally launched in 2003 as a blogging platform, it has evolved into a comprehensive CMS that supports everything from simple blogs to complex enterprise websites. When combined with WooCommerce, WordPress transforms into a powerful e-commerce platform capable of handling everything from small online stores to large-scale retail operations with millions of products. This stack combines WordPress and WooCommerce with MySQL for robust data storage, Redis for high-performance caching and session management, Elasticsearch for advanced product search capabilities, and NGINX as a high-performance web server and reverse proxy. MySQL's InnoDB storage engine provides ACID compliance for transactional integrity crucial for e-commerce operations, while Redis delivers sub-millisecond response times for cart data and user sessions. Elasticsearch enables sophisticated product search with relevance scoring and faceted navigation, and NGINX's event-driven architecture handles high-traffic loads efficiently. This configuration is ideal for businesses launching serious e-commerce operations, developers building custom online stores, and agencies managing multiple client shops. The combination provides enterprise-grade performance and scalability while maintaining WordPress's ease of use. With WooCommerce's extensive payment gateway integrations, Redis caching for improved page load times, and Elasticsearch's advanced search capabilities, this stack can handle everything from boutique stores to high-volume marketplaces with complex product catalogs.

Key Features

  • WooCommerce integration with 100+ payment gateways including PayPal, Stripe, and Square
  • Redis Object Cache for sub-millisecond session storage and database query caching
  • Elasticsearch full-text search with relevance scoring and product filtering
  • MySQL InnoDB storage engine with ACID compliance for secure transaction processing
  • NGINX reverse proxy with HTTP/2 support and SSL/TLS termination
  • WordPress plugin ecosystem with 60,000+ plugins for unlimited functionality
  • ElasticPress integration for advanced product search and analytics
  • Redis-based cart persistence and user session management

Common Use Cases

  • 1High-traffic online stores requiring fast product search and checkout processes
  • 2Multi-vendor marketplaces with complex product catalogs and search requirements
  • 3B2B e-commerce platforms with custom pricing and bulk ordering capabilities
  • 4Digital product stores selling software, courses, or subscription services
  • 5Fashion or electronics retailers needing advanced filtering and search functionality
  • 6International e-commerce sites requiring multiple payment methods and currencies
  • 7Dropshipping businesses managing large product inventories from multiple suppliers

Prerequisites

  • Docker Engine 20.10+ and Docker Compose 2.0+ installed
  • Minimum 4GB RAM (2GB for Elasticsearch, 1GB for WordPress/MySQL, 512MB for Redis)
  • At least 10GB available disk space for WordPress files and database storage
  • Ports 80, 443, and 8081 available on the host system
  • Basic understanding of WordPress administration and WooCommerce configuration
  • SSL certificates for production deployment (self-signed acceptable for development)

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.0
4 environment:
5 - MYSQL_DATABASE=wordpress
6 - MYSQL_USER=wordpress
7 - MYSQL_PASSWORD=${MYSQL_PASSWORD}
8 - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
9 volumes:
10 - mysql_data:/var/lib/mysql
11 networks:
12 - woo_net
13
14 redis:
15 image: redis:7-alpine
16 volumes:
17 - redis_data:/data
18 networks:
19 - woo_net
20
21 elasticsearch:
22 image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
23 environment:
24 - discovery.type=single-node
25 - xpack.security.enabled=false
26 - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
27 volumes:
28 - es_data:/usr/share/elasticsearch/data
29 networks:
30 - woo_net
31
32 wordpress:
33 image: wordpress:latest
34 environment:
35 - WORDPRESS_DB_HOST=mysql
36 - WORDPRESS_DB_NAME=wordpress
37 - WORDPRESS_DB_USER=wordpress
38 - WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD}
39 - WORDPRESS_CONFIG_EXTRA=
40 define('WP_REDIS_HOST', 'redis');
41 define('WP_REDIS_PORT', 6379);
42 volumes:
43 - wordpress_data:/var/www/html
44 depends_on:
45 - mysql
46 - redis
47 networks:
48 - woo_net
49
50 nginx:
51 image: nginx:alpine
52 ports:
53 - "80:80"
54 - "443:443"
55 volumes:
56 - ./nginx.conf:/etc/nginx/nginx.conf:ro
57 - wordpress_data:/var/www/html:ro
58 - ./ssl:/etc/nginx/ssl:ro
59 depends_on:
60 - wordpress
61 networks:
62 - woo_net
63
64 phpmyadmin:
65 image: phpmyadmin:latest
66 ports:
67 - "8081:80"
68 environment:
69 - PMA_HOST=mysql
70 - PMA_USER=wordpress
71 - PMA_PASSWORD=${MYSQL_PASSWORD}
72 depends_on:
73 - mysql
74 networks:
75 - woo_net
76
77volumes:
78 mysql_data:
79 redis_data:
80 es_data:
81 wordpress_data:
82
83networks:
84 woo_net:

.env Template

.env
1# WooCommerce
2MYSQL_PASSWORD=secure_mysql_password
3MYSQL_ROOT_PASSWORD=secure_root_password
4
5# WordPress at http://localhost
6# phpMyAdmin at http://localhost:8081

Usage Notes

  1. 1WordPress at http://localhost
  2. 2phpMyAdmin at http://localhost:8081
  3. 3Install WooCommerce via WordPress admin
  4. 4Redis Object Cache plugin recommended
  5. 5ElasticPress for Elasticsearch integration

Individual Services(6 services)

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

mysql
mysql:
  image: mysql:8.0
  environment:
    - MYSQL_DATABASE=wordpress
    - MYSQL_USER=wordpress
    - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
  volumes:
    - mysql_data:/var/lib/mysql
  networks:
    - woo_net
redis
redis:
  image: redis:7-alpine
  volumes:
    - redis_data:/data
  networks:
    - woo_net
elasticsearch
elasticsearch:
  image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
  environment:
    - discovery.type=single-node
    - xpack.security.enabled=false
    - ES_JAVA_OPTS=-Xms512m -Xmx512m
  volumes:
    - es_data:/usr/share/elasticsearch/data
  networks:
    - woo_net
wordpress
wordpress:
  image: wordpress:latest
  environment:
    - WORDPRESS_DB_HOST=mysql
    - WORDPRESS_DB_NAME=wordpress
    - WORDPRESS_DB_USER=wordpress
    - WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD}
    - WORDPRESS_CONFIG_EXTRA= define('WP_REDIS_HOST', 'redis'); define('WP_REDIS_PORT', 6379);
  volumes:
    - wordpress_data:/var/www/html
  depends_on:
    - mysql
    - redis
  networks:
    - woo_net
nginx
nginx:
  image: nginx:alpine
  ports:
    - "80:80"
    - "443:443"
  volumes:
    - ./nginx.conf:/etc/nginx/nginx.conf:ro
    - wordpress_data:/var/www/html:ro
    - ./ssl:/etc/nginx/ssl:ro
  depends_on:
    - wordpress
  networks:
    - woo_net
phpmyadmin
phpmyadmin:
  image: phpmyadmin:latest
  ports:
    - "8081:80"
  environment:
    - PMA_HOST=mysql
    - PMA_USER=wordpress
    - PMA_PASSWORD=${MYSQL_PASSWORD}
  depends_on:
    - mysql
  networks:
    - woo_net

Quick Start

terminal
1# 1. Create the compose file
2cat > docker-compose.yml << 'EOF'
3services:
4 mysql:
5 image: mysql:8.0
6 environment:
7 - MYSQL_DATABASE=wordpress
8 - MYSQL_USER=wordpress
9 - MYSQL_PASSWORD=${MYSQL_PASSWORD}
10 - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
11 volumes:
12 - mysql_data:/var/lib/mysql
13 networks:
14 - woo_net
15
16 redis:
17 image: redis:7-alpine
18 volumes:
19 - redis_data:/data
20 networks:
21 - woo_net
22
23 elasticsearch:
24 image: docker.elastic.co/elasticsearch/elasticsearch:8.11.0
25 environment:
26 - discovery.type=single-node
27 - xpack.security.enabled=false
28 - "ES_JAVA_OPTS=-Xms512m -Xmx512m"
29 volumes:
30 - es_data:/usr/share/elasticsearch/data
31 networks:
32 - woo_net
33
34 wordpress:
35 image: wordpress:latest
36 environment:
37 - WORDPRESS_DB_HOST=mysql
38 - WORDPRESS_DB_NAME=wordpress
39 - WORDPRESS_DB_USER=wordpress
40 - WORDPRESS_DB_PASSWORD=${MYSQL_PASSWORD}
41 - WORDPRESS_CONFIG_EXTRA=
42 define('WP_REDIS_HOST', 'redis');
43 define('WP_REDIS_PORT', 6379);
44 volumes:
45 - wordpress_data:/var/www/html
46 depends_on:
47 - mysql
48 - redis
49 networks:
50 - woo_net
51
52 nginx:
53 image: nginx:alpine
54 ports:
55 - "80:80"
56 - "443:443"
57 volumes:
58 - ./nginx.conf:/etc/nginx/nginx.conf:ro
59 - wordpress_data:/var/www/html:ro
60 - ./ssl:/etc/nginx/ssl:ro
61 depends_on:
62 - wordpress
63 networks:
64 - woo_net
65
66 phpmyadmin:
67 image: phpmyadmin:latest
68 ports:
69 - "8081:80"
70 environment:
71 - PMA_HOST=mysql
72 - PMA_USER=wordpress
73 - PMA_PASSWORD=${MYSQL_PASSWORD}
74 depends_on:
75 - mysql
76 networks:
77 - woo_net
78
79volumes:
80 mysql_data:
81 redis_data:
82 es_data:
83 wordpress_data:
84
85networks:
86 woo_net:
87EOF
88
89# 2. Create the .env file
90cat > .env << 'EOF'
91# WooCommerce
92MYSQL_PASSWORD=secure_mysql_password
93MYSQL_ROOT_PASSWORD=secure_root_password
94
95# WordPress at http://localhost
96# phpMyAdmin at http://localhost:8081
97EOF
98
99# 3. Start the services
100docker compose up -d
101
102# 4. View logs
103docker 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-complete/run | bash

Troubleshooting

  • Elasticsearch container exits with 'max virtual memory areas vm.max_map_count too low': Run 'sudo sysctl -w vm.max_map_count=262144' on the host system
  • WordPress shows 'Error establishing a database connection': Verify MYSQL_PASSWORD environment variable matches in both wordpress and mysql services
  • Redis Object Cache plugin shows 'Connection refused': Ensure Redis container is running and WordPress container can reach redis:6379
  • WooCommerce product search returns no results: Install and configure ElasticPress plugin to connect WordPress to the elasticsearch container
  • NGINX returns 502 Bad Gateway: Check that wordpress container is healthy and nginx.conf has correct upstream configuration pointing to wordpress:80
  • phpMyAdmin access denied: Verify PMA_PASSWORD matches MYSQL_PASSWORD and mysql container is fully initialized before accessing

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