docker.recipes

WooCommerce

beginner

WordPress-based e-commerce platform.

Overview

WooCommerce is the world's most popular e-commerce plugin for WordPress, powering over 5 million online stores globally. Built as an extension to WordPress, it transforms the content management system into a fully-featured e-commerce platform capable of selling physical products, digital downloads, subscriptions, and services. WooCommerce leverages WordPress's flexibility and extensive ecosystem while adding specialized e-commerce functionality like inventory management, payment processing, shipping calculations, and tax handling. This Docker stack combines WordPress with MySQL 8.0 to create a complete WooCommerce hosting environment. WordPress serves as the application layer running WooCommerce, while MySQL provides the relational database backend storing product catalogs, customer data, orders, and inventory information. The MySQL InnoDB storage engine ensures ACID compliance for financial transactions, while WordPress's plugin architecture allows unlimited customization of the store's functionality and appearance. This configuration is ideal for entrepreneurs launching online stores, developers building custom e-commerce solutions, and agencies managing multiple client shops. The combination provides enterprise-grade database reliability with WordPress's user-friendly interface, making it accessible to non-technical users while offering the flexibility developers need for complex customizations. WooCommerce's REST API enables headless commerce implementations and third-party integrations with CRM systems, inventory management tools, and marketing platforms.

Key Features

  • Complete WooCommerce e-commerce platform with product management, inventory tracking, and order processing
  • WordPress Gutenberg block editor with WooCommerce product blocks for visual store building
  • MySQL 8.0 with InnoDB storage engine providing ACID compliance for financial transactions
  • Built-in payment gateway support for Stripe, PayPal, Square, and 100+ other processors
  • Comprehensive tax calculation system with support for multiple tax classes and jurisdictions
  • Advanced shipping options including flat rate, free shipping, local pickup, and real-time carrier rates
  • WooCommerce REST API for headless commerce and third-party integrations
  • Extensive reporting dashboard with sales analytics, customer insights, and inventory reports

Common Use Cases

  • 1Small to medium online retail stores selling physical products with inventory management
  • 2Digital product marketplaces selling software, ebooks, courses, and downloadable content
  • 3Subscription-based businesses offering recurring billing for services or products
  • 4B2B wholesale platforms with custom pricing tiers and bulk ordering capabilities
  • 5Multi-vendor marketplaces where multiple sellers can list and manage their products
  • 6Local businesses adding online ordering and pickup/delivery options to their services
  • 7Agencies developing custom e-commerce solutions for clients with specific requirements

Prerequisites

  • Minimum 1GB RAM recommended for WordPress and WooCommerce operation under normal load
  • Port 8080 available for web access to the WordPress/WooCommerce frontend
  • Environment variables configured: MYSQL_ROOT_PASSWORD, MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD
  • Basic WordPress administration knowledge for initial setup and WooCommerce configuration
  • Understanding of e-commerce concepts like payment gateways, shipping zones, and tax settings
  • SSL certificate setup knowledge for production deployment handling customer payment data

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: mysql
8 WORDPRESS_DB_USER: ${MYSQL_USER}
9 WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
10 WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
11 volumes:
12 - wordpress_data:/var/www/html
13 ports:
14 - "8080:80"
15 depends_on:
16 - mysql
17 networks:
18 - woo
19
20 mysql:
21 image: mysql:8.0
22 container_name: woo-mysql
23 environment:
24 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
25 MYSQL_DATABASE: ${MYSQL_DATABASE}
26 MYSQL_USER: ${MYSQL_USER}
27 MYSQL_PASSWORD: ${MYSQL_PASSWORD}
28 volumes:
29 - mysql_data:/var/lib/mysql
30 networks:
31 - woo
32
33volumes:
34 wordpress_data:
35 mysql_data:
36
37networks:
38 woo:
39 driver: bridge

.env Template

.env
1MYSQL_ROOT_PASSWORD=rootpassword
2MYSQL_DATABASE=woocommerce
3MYSQL_USER=woocommerce
4MYSQL_PASSWORD=changeme

Usage Notes

  1. 1Docs: https://woocommerce.com/documentation/
  2. 2Access at http://localhost:8080 - complete WordPress setup wizard first
  3. 3Install WooCommerce from Plugins > Add New, then run setup wizard
  4. 4Storefront theme recommended for WooCommerce compatibility
  5. 5Configure payment gateways: Stripe, PayPal, Square plugins available
  6. 6REST API available at /wp-json/wc/v3/ for integrations

Individual Services(2 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: mysql
    WORDPRESS_DB_USER: ${MYSQL_USER}
    WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
    WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
  volumes:
    - wordpress_data:/var/www/html
  ports:
    - "8080:80"
  depends_on:
    - mysql
  networks:
    - woo
mysql
mysql:
  image: mysql:8.0
  container_name: woo-mysql
  environment:
    MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
    MYSQL_DATABASE: ${MYSQL_DATABASE}
    MYSQL_USER: ${MYSQL_USER}
    MYSQL_PASSWORD: ${MYSQL_PASSWORD}
  volumes:
    - mysql_data:/var/lib/mysql
  networks:
    - woo

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: mysql
10 WORDPRESS_DB_USER: ${MYSQL_USER}
11 WORDPRESS_DB_PASSWORD: ${MYSQL_PASSWORD}
12 WORDPRESS_DB_NAME: ${MYSQL_DATABASE}
13 volumes:
14 - wordpress_data:/var/www/html
15 ports:
16 - "8080:80"
17 depends_on:
18 - mysql
19 networks:
20 - woo
21
22 mysql:
23 image: mysql:8.0
24 container_name: woo-mysql
25 environment:
26 MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
27 MYSQL_DATABASE: ${MYSQL_DATABASE}
28 MYSQL_USER: ${MYSQL_USER}
29 MYSQL_PASSWORD: ${MYSQL_PASSWORD}
30 volumes:
31 - mysql_data:/var/lib/mysql
32 networks:
33 - woo
34
35volumes:
36 wordpress_data:
37 mysql_data:
38
39networks:
40 woo:
41 driver: bridge
42EOF
43
44# 2. Create the .env file
45cat > .env << 'EOF'
46MYSQL_ROOT_PASSWORD=rootpassword
47MYSQL_DATABASE=woocommerce
48MYSQL_USER=woocommerce
49MYSQL_PASSWORD=changeme
50EOF
51
52# 3. Start the services
53docker compose up -d
54
55# 4. View logs
56docker 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/run | bash

Troubleshooting

  • WordPress database connection error: Verify MySQL container is running and environment variables match between services
  • WooCommerce setup wizard not appearing: Ensure WooCommerce plugin is installed and activated from WordPress admin plugins page
  • MySQL container failing to start: Check that MYSQL_ROOT_PASSWORD environment variable is set and contains valid characters
  • WordPress showing database establishment error: Wait for MySQL container to fully initialize before WordPress starts, typically 30-60 seconds
  • WooCommerce products not saving: Increase WordPress memory limit by adding WORDPRESS_CONFIG_EXTRA environment variable with memory_limit setting
  • Payment gateway connection failures: Verify SSL/TLS configuration as most payment processors require secure connections for API communication

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