# OpenCart Store

> OpenCart ecommerce platform with MySQL.

- Category: E-Commerce & Business
- Difficulty: beginner
- Components: opencart, mysql
- Tags: opencart, ecommerce, php, mysql, store
- Source: https://docker.recipes/ecommerce/opencart-store

## Overview

OpenCart is a free, open-source PHP-based e-commerce platform that has powered over 350,000 online stores since 2009. Built with simplicity in mind, OpenCart offers a complete shopping cart solution with multi-store management, extensive theme customization, and over 13,000 modules and themes available through its marketplace. The platform supports multiple languages, currencies, and payment gateways, making it ideal for businesses looking to establish an international online presence without the complexity of enterprise-level platforms.

This stack combines OpenCart with MySQL 8.0 to create a robust e-commerce environment where MySQL's InnoDB storage engine handles transactional integrity for orders, inventory, and customer data. MySQL's query cache optimizes performance for product catalogs and search functionality, while OpenCart's PHP architecture leverages MySQL's full-text search capabilities for product filtering and customer searches. The Bitnami OpenCart image includes pre-configured PHP extensions and optimization settings that work efficiently with MySQL's connection pooling and prepared statements.

This configuration serves online retailers, dropshipping businesses, and entrepreneurs who need a complete e-commerce solution with reliable data persistence and scalability. The combination is particularly valuable for businesses expecting moderate to high transaction volumes, as MySQL's ACID compliance ensures order integrity while OpenCart's multi-store capabilities allow management of multiple brands or regional stores from a single installation.

## Features

- OpenCart's multi-store architecture allowing unlimited stores from single admin panel with shared customer database
- MySQL InnoDB storage engine with ACID compliance for transactional integrity of orders and payments
- OpenCart marketplace integration with 13,000+ extensions and themes accessible from admin interface
- MySQL full-text indexing optimized for OpenCart's product search and category filtering
- OpenCart's built-in SEO URL system with MySQL database-driven URL rewriting
- Bitnami OpenCart image with pre-configured PHP-FPM and MySQL connection optimization
- OpenCart's multi-currency and multi-language support with MySQL UTF-8 character set handling
- MySQL Group Replication compatibility for high-availability e-commerce deployments

## Use cases

- Small to medium online retailers launching product catalogs with integrated payment processing
- Dropshipping businesses managing supplier catalogs and automated order fulfillment workflows
- Multi-brand retailers operating separate storefronts with consolidated inventory management
- International e-commerce sites requiring multi-currency pricing and localized product descriptions
- Digital agencies developing custom e-commerce solutions for clients with OpenCart extensions
- B2B wholesale platforms with customer-specific pricing and restricted product access
- Marketplace operators hosting multiple vendor stores with centralized order processing

## Prerequisites

- Minimum 2GB RAM recommended for OpenCart with moderate product catalogs and concurrent users
- Ports 80 and 443 available for HTTP/HTTPS traffic to OpenCart storefront and admin panel
- Basic understanding of OpenCart admin interface for store configuration and product management
- Familiarity with MySQL backup procedures for protecting customer and order data
- Knowledge of PHP configuration for OpenCart performance tuning and extension installation
- SSL certificate management experience for securing customer checkout and payment processes

## docker-compose.yml

```yaml
services:
  mysql:
    image: mysql:8.0
    container_name: opencart-mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD:-root}
      MYSQL_DATABASE: ${MYSQL_DATABASE:-opencart}
      MYSQL_USER: ${MYSQL_USER:-opencart}
      MYSQL_PASSWORD: ${MYSQL_PASSWORD:-opencart}
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - opencart-network

  opencart:
    image: bitnami/opencart:latest
    container_name: opencart
    restart: unless-stopped
    ports:
      - "${OPENCART_PORT:-80}:8080"
      - "${OPENCART_HTTPS_PORT:-443}:8443"
    environment:
      - OPENCART_HOST=localhost
      - OPENCART_DATABASE_HOST=mysql
      - OPENCART_DATABASE_NAME=${MYSQL_DATABASE:-opencart}
      - OPENCART_DATABASE_USER=${MYSQL_USER:-opencart}
      - OPENCART_DATABASE_PASSWORD=${MYSQL_PASSWORD:-opencart}
      - OPENCART_USERNAME=${OPENCART_USER:-admin}
      - OPENCART_PASSWORD=${OPENCART_PASSWORD:-admin123}
      - OPENCART_EMAIL=${OPENCART_EMAIL:-admin@example.com}
    volumes:
      - opencart_data:/bitnami/opencart
    depends_on:
      - mysql
    networks:
      - opencart-network

volumes:
  mysql_data:
  opencart_data:

networks:
  opencart-network:
    driver: bridge
```

## .env

```bash
# OpenCart
OPENCART_PORT=80
OPENCART_HTTPS_PORT=443
MYSQL_ROOT_PASSWORD=root
MYSQL_DATABASE=opencart
MYSQL_USER=opencart
MYSQL_PASSWORD=opencart
OPENCART_USER=admin
OPENCART_PASSWORD=admin123
OPENCART_EMAIL=admin@example.com
```

## Usage notes

- Docs: https://docs.opencart.com/
- Storefront at http://localhost, admin at /admin
- Login: use OPENCART_USER/OPENCART_PASSWORD from env
- Extension marketplace: Extensions > Marketplace in admin
- SEO URLs: enable in System > Settings > Server tab
- Multi-store support built-in - configure in System > Settings

## Troubleshooting

- OpenCart installation wizard fails to connect: Verify OPENCART_DATABASE_HOST points to 'mysql' service name and database credentials match
- Product images not displaying after restart: Check opencart_data volume mount and ensure /bitnami/opencart/image directory permissions are correct
- MySQL connection limit errors during high traffic: Increase MySQL max_connections parameter and configure OpenCart database connection pooling
- OpenCart admin login redirects to setup: Delete install directory from opencart_data volume or set OPENCART_SKIP_INSTALL=yes environment variable
- Payment gateway SSL errors: Configure OPENCART_HOST with actual domain name instead of localhost for production deployments
- OpenCart marketplace extensions fail to install: Ensure container has write permissions to /bitnami/opencart and sufficient disk space in volume

