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

  1. Open http://your-server-ip:8080 in your browser
  2. Select your language and click Continue
  3. Enter your site title, admin username, password, and email
  4. Click Install WordPress
  5. Log in to the WordPress admin panel at /wp-admin

Install WooCommerce

From the WordPress admin panel:

  1. Navigate to Plugins → Add New Plugin
  2. Search for “WooCommerce”
  3. Click Install Now, then Activate
  4. 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

SettingLocationRecommended Value
Store addressWooCommerce → Settings → GeneralYour business address
CurrencyWooCommerce → Settings → GeneralYour local currency
Tax calculationWooCommerce → Settings → TaxEnable if selling physical goods
Shipping zonesWooCommerce → Settings → ShippingConfigure per region
Payment gatewaysWooCommerce → Settings → PaymentsStripe or PayPal (requires HTTPS)
Email notificationsWooCommerce → Settings → EmailsConfigure 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:

  1. Go to WooCommerce → Settings → Advanced → REST API
  2. Click Add key — set permissions to Read/Write
  3. 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:

FieldValue
Domainstore.yourdomain.com
Schemehttp
Forward Hostnameyour-server-ip
Forward Port8080
SSLRequest 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

ResourceMinimumRecommended
RAM1 GB2 GB (4 GB for large catalogs)
CPU1 core2 cores
Disk5 GB20 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.

Frequently Asked Questions

How does WooCommerce compare to Shopify?

WooCommerce is free and self-hosted — you own your data and pay no platform fees. Shopify charges $39-399/month plus transaction fees. WooCommerce offers unlimited customization through WordPress plugins, but requires you to manage hosting, security, and updates. Shopify handles infrastructure but locks you into their ecosystem. For technical users who want control, WooCommerce wins. For non-technical users who want simplicity, Shopify is easier.

Is WooCommerce truly free?

The core WooCommerce plugin is free (GPLv3). However, many useful extensions (payment gateways, shipping calculators, advanced reporting) are paid plugins ranging from $49-299/year each. You also pay for hosting, a domain, and SSL certificate. Total cost for a production store is typically $10-50/month for hosting versus $39-399/month for Shopify.

Can WooCommerce handle high traffic?

Yes, with proper infrastructure. The Docker Compose setup in this guide includes Redis for object caching, which significantly improves performance. For stores with 500+ products or heavy concurrent traffic, consider adding a CDN, increasing PHP workers, and using a dedicated database server. WooCommerce powers stores doing millions in revenue — the platform scales with infrastructure.

Does WooCommerce work without a domain name?

Technically yes, but not practically. Payment gateways (Stripe, PayPal) require HTTPS, which requires a domain name. You can test WooCommerce on localhost or an IP address, but you cannot process real payments without a domain and SSL certificate.

Can I migrate from Shopify to WooCommerce?

Yes. WooCommerce has import tools for products, customers, and orders from Shopify. Several plugins (Cart2Cart, LitExtension) automate the migration. Product data, images, and customer information transfer well. Order history also migrates but may need manual review. The biggest effort is recreating your theme/design in WordPress.

How do I keep WooCommerce secure?

Keep WordPress, WooCommerce, and all plugins updated. Use strong admin passwords and enable two-factor authentication. Limit login attempts (Wordfence or Limit Login Attempts plugins). Always use HTTPS. Restrict wp-admin access by IP if possible. Run regular backups — see Backup Strategy. The Docker setup provides container isolation, but WordPress plugin security remains your responsibility.

Comments