Self-Host WooCommerce with Docker Compose
What Is WooCommerce?
WooCommerce is the most popular open-source e-commerce platform, running as a WordPress plugin. It powers over 30% of all online stores. Self-hosting WooCommerce gives you full control over your store data, zero transaction fees from the platform, and unlimited customization through WordPress’s plugin ecosystem. It replaces Shopify ($39-399/month), BigCommerce, and Squarespace Commerce.
Updated February 2026: Verified with latest Docker images and configurations.
Official site: woocommerce.com
Prerequisites
- A Linux server (Ubuntu 22.04+ recommended)
- Docker and Docker Compose installed (guide)
- 2 GB of free RAM (minimum)
- 10 GB of free disk space
- A domain name (required for payment gateways — HTTPS is mandatory)
Docker Compose Configuration
Create a docker-compose.yml file:
services:
wordpress:
image: wordpress:6.7.2-apache
restart: unless-stopped
ports:
- "8080:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: woocommerce
WORDPRESS_DB_USER: woocommerce
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
WORDPRESS_TABLE_PREFIX: wp_
WORDPRESS_CONFIG_EXTRA: |
define('WP_REDIS_HOST', 'redis');
define('WP_REDIS_PORT', 6379);
define('WP_MEMORY_LIMIT', '256M');
define('WP_MAX_MEMORY_LIMIT', '512M');
define('WOOCOMMERCE_USE_ACTION_SCHEDULER', true);
volumes:
- wordpress_data:/var/www/html
networks:
- woo_network
depends_on:
db:
condition: service_healthy
db:
image: mariadb:11.4
restart: unless-stopped
environment:
MYSQL_DATABASE: woocommerce
MYSQL_USER: woocommerce
MYSQL_PASSWORD: ${DB_PASSWORD}
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
volumes:
- db_data:/var/lib/mysql
networks:
- woo_network
healthcheck:
test: ["CMD", "healthcheck.sh", "--connect", "--innodb_initialized"]
interval: 10s
timeout: 5s
retries: 5
redis:
image: redis:7.4-alpine
restart: unless-stopped
command: redis-server --maxmemory 128mb --maxmemory-policy allkeys-lru
volumes:
- redis_data:/data
networks:
- woo_network
wpcli:
image: wordpress:cli-2.11.0
depends_on:
- wordpress
volumes:
- wordpress_data:/var/www/html
networks:
- woo_network
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_NAME: woocommerce
WORDPRESS_DB_USER: woocommerce
WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
profiles:
- cli
volumes:
wordpress_data:
db_data:
redis_data:
networks:
woo_network:
Create a .env file alongside your docker-compose.yml:
# Database credentials — CHANGE THESE
DB_PASSWORD=your-strong-database-password-here
DB_ROOT_PASSWORD=your-strong-root-password-here
Start the stack:
docker compose up -d
Initial Setup
- Open
http://your-server-ip:8080in your browser - Select your language and click Continue
- Enter your site title, admin username, password, and email
- Click Install WordPress
- Log in to the WordPress admin panel at
/wp-admin
Install WooCommerce
From the WordPress admin panel:
- Navigate to Plugins → Add New Plugin
- Search for “WooCommerce”
- Click Install Now, then Activate
- The WooCommerce Setup Wizard launches — follow the prompts to configure your store (currency, shipping zones, payment methods)
Or install via WP-CLI:
docker compose run --rm wpcli wp plugin install woocommerce --activate
Install Redis Object Cache
WooCommerce performance improves significantly with Redis caching:
docker compose run --rm wpcli wp plugin install redis-cache --activate
docker compose run --rm wpcli wp redis enable
Configuration
Essential WooCommerce Settings
| Setting | Location | Recommended Value |
|---|---|---|
| Store address | WooCommerce → Settings → General | Your business address |
| Currency | WooCommerce → Settings → General | Your local currency |
| Tax calculation | WooCommerce → Settings → Tax | Enable if selling physical goods |
| Shipping zones | WooCommerce → Settings → Shipping | Configure per region |
| Payment gateways | WooCommerce → Settings → Payments | Stripe or PayPal (requires HTTPS) |
| Email notifications | WooCommerce → Settings → Emails | Configure SMTP for reliability |
Performance Tuning
Add these constants to your WORDPRESS_CONFIG_EXTRA for production:
define('WP_POST_REVISIONS', 5); // Limit post revisions
define('EMPTY_TRASH_DAYS', 7); // Auto-delete trash after 7 days
define('WP_CRON_LOCK_TIMEOUT', 120); // Prevent cron overlap
define('DISABLE_WP_CRON', false); // Keep WP-Cron for WooCommerce scheduled tasks
Advanced Configuration (Optional)
SMTP for Order Emails
Install WP Mail SMTP to ensure order confirmation emails are delivered:
docker compose run --rm wpcli wp plugin install wp-mail-smtp --activate
Configure with your SMTP provider (Resend, Mailgun, or SendGrid) in WP Mail SMTP → Settings.
Stripe Payment Gateway
docker compose run --rm wpcli wp plugin install woocommerce-gateway-stripe --activate
Configure at WooCommerce → Settings → Payments → Stripe. You need:
- A Stripe account (free to create)
- Your Publishable Key and Secret Key from the Stripe Dashboard
- HTTPS enabled on your domain (mandatory for payment processing)
WooCommerce REST API
Enable the REST API for headless commerce or integrations:
- Go to WooCommerce → Settings → Advanced → REST API
- Click Add key — set permissions to Read/Write
- Use the Consumer Key and Consumer Secret for API access
Reverse Proxy
HTTPS is mandatory for WooCommerce — payment gateways reject HTTP connections.
Example Nginx Proxy Manager configuration:
| Field | Value |
|---|---|
| Domain | store.yourdomain.com |
| Scheme | http |
| Forward Hostname | your-server-ip |
| Forward Port | 8080 |
| SSL | Request a new certificate |
After setting up the reverse proxy, update WordPress URLs:
docker compose run --rm wpcli wp option update siteurl 'https://store.yourdomain.com'
docker compose run --rm wpcli wp option update home 'https://store.yourdomain.com'
For more details: Reverse Proxy Setup
Backup
WooCommerce stores critical business data — orders, customers, products. Back up both the WordPress files and database.
Database Backup
docker compose exec db mysqldump -u woocommerce -p woocommerce > woocommerce-backup.sql
File Backup
Back up the wordpress_data volume, which contains uploads, plugins, and themes:
docker run --rm -v wordpress_data:/data -v $(pwd):/backup alpine tar czf /backup/wordpress-files.tar.gz -C /data .
Schedule daily backups with cron. For a comprehensive approach: Backup Strategy
Troubleshooting
WooCommerce Setup Wizard Not Loading
Symptom: Blank page or 500 error during WooCommerce setup
Fix: Increase PHP memory limit in the WORDPRESS_CONFIG_EXTRA environment variable:
define('WP_MEMORY_LIMIT', '512M');
Restart the container: docker compose restart wordpress
Payment Gateway Says “HTTPS Required”
Symptom: Stripe or PayPal refuses to connect Fix: Set up a reverse proxy with SSL. Then force HTTPS in WordPress:
docker compose run --rm wpcli wp option update siteurl 'https://your-domain.com'
docker compose run --rm wpcli wp option update home 'https://your-domain.com'
Slow Page Loads with Large Product Catalogs
Symptom: Pages take 3-5+ seconds to load with 500+ products Fix: Ensure Redis is running and the Redis Object Cache plugin is activated. Verify with:
docker compose run --rm wpcli wp redis status
If Redis shows “Not connected,” check that the WP_REDIS_HOST constant matches your Redis container name.
Emails Not Sending
Symptom: Order confirmation and password reset emails not delivered
Fix: WordPress’s built-in wp_mail() uses PHP mail(), which most Docker containers don’t configure. Install WP Mail SMTP and configure an external SMTP provider.
Database Connection Error After Restart
Symptom: “Error establishing a database connection” after docker compose restart
Fix: MariaDB may not be ready yet. The depends_on with condition: service_healthy in the Compose file handles this. If the issue persists, check MariaDB logs:
docker compose logs db
Resource Requirements
| Resource | Minimum | Recommended |
|---|---|---|
| RAM | 1 GB | 2 GB (4 GB for large catalogs) |
| CPU | 1 core | 2 cores |
| Disk | 5 GB | 20 GB+ (depends on product images) |
WooCommerce with Redis uses approximately 400-600 MB RAM idle. Under load with concurrent shoppers, expect 800 MB - 1.5 GB.
Verdict
WooCommerce is the best self-hosted e-commerce platform for most people. Its WordPress foundation means access to thousands of themes, payment gateways, shipping plugins, and SEO tools. The trade-off is complexity — WordPress requires more maintenance than purpose-built platforms like Saleor or Medusa. If you want a headless API-first store, look at Saleor. If you want a traditional storefront with the largest plugin ecosystem, WooCommerce is the clear winner.
Related
- Saleor vs WooCommerce: Headless vs Traditional
- WooCommerce vs PrestaShop: Which E-Commerce Platform?
- Best Self-Hosted E-Commerce Platforms
- Self-Hosted Alternatives to Shopify
- How to Self-Host Saleor
- How to Self-Host Medusa
- How to Self-Host PrestaShop
- Medusa vs Saleor
- Saleor vs PrestaShop
- Docker Compose Basics
- Reverse Proxy Setup
- Backup Strategy
Get self-hosting tips in your inbox
Get the Docker Compose configs, hardware picks, and setup shortcuts we don't put in articles. Weekly. No spam.
Comments