docker.recipes

OpenCart E-commerce Platform

beginner

Lightweight e-commerce platform with OpenCart, MySQL, and extensions.

Overview

OpenCart is an open-source PHP-based e-commerce platform that has been powering online stores since 2008. Known for its user-friendly interface and extensive marketplace of themes and extensions, OpenCart provides a lightweight alternative to heavyweight e-commerce solutions like Magento. The platform features a clean admin panel, multi-store support, and over 13,000 modules and themes available through its marketplace, making it popular among small to medium-sized businesses looking to establish an online presence quickly. This stack combines OpenCart with MySQL 8.0 for robust data storage, Redis for high-performance session management and caching, and includes phpMyAdmin for database administration. MySQL's InnoDB storage engine provides ACID compliance for transaction integrity, while Redis delivers sub-millisecond response times for cart sessions and product caching. The Bitnami OpenCart image comes pre-configured with PHP-FPM and Apache, eliminating the complexity of manual PHP environment setup while maintaining the flexibility to customize themes and extensions. This configuration is ideal for entrepreneurs launching their first online store, web developers building client e-commerce sites, or businesses migrating from hosted solutions like Shopify to self-hosted platforms. The lightweight nature of OpenCart combined with Redis caching makes this stack capable of handling moderate traffic loads while keeping resource requirements minimal, making it cost-effective for smaller businesses or development environments where performance and simplicity are more important than enterprise-scale features.

Key Features

  • OpenCart's 13,000+ extension marketplace for payment gateways, shipping modules, and marketing tools
  • MySQL 8.0 InnoDB storage engine with ACID compliance for order and inventory transaction integrity
  • Redis in-memory caching for lightning-fast shopping cart sessions and product catalog performance
  • Multi-store capability allowing management of multiple storefronts from single OpenCart installation
  • Built-in SEO optimization with URL rewriting and meta tag management for search engine visibility
  • phpMyAdmin web interface for direct database management of products, orders, and customer data
  • OpenCart's drag-and-drop layout system for customizing storefront appearance without coding
  • Comprehensive admin dashboard with real-time sales analytics and inventory tracking

Common Use Cases

  • 1Small business owners launching their first online store with limited technical expertise
  • 2Web development agencies building custom e-commerce sites for multiple clients
  • 3Existing brick-and-mortar stores adding online sales channels with inventory synchronization
  • 4Digital product sellers needing lightweight platform for downloadable goods and services
  • 5International businesses requiring multi-currency and multi-language e-commerce capabilities
  • 6Dropshipping operations needing automated order processing and supplier integration
  • 7Development teams prototyping e-commerce features before production deployment

Prerequisites

  • Minimum 2GB RAM recommended (MySQL 1GB + Redis 512MB + OpenCart 512MB + system overhead)
  • Ports 80, 443, and 8081 available on host system for web access and phpMyAdmin
  • Basic understanding of OpenCart admin panel for initial store configuration and product setup
  • SSL certificate files if enabling HTTPS for production e-commerce transactions
  • SMTP email credentials for order notifications and customer communication features
  • Domain name and DNS configuration for production deployment accessibility

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=opencart
6 - MYSQL_USER=opencart
7 - MYSQL_PASSWORD=${MYSQL_PASSWORD}
8 - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
9 volumes:
10 - mysql_data:/var/lib/mysql
11 networks:
12 - opencart_net
13
14 redis:
15 image: redis:7-alpine
16 volumes:
17 - redis_data:/data
18 networks:
19 - opencart_net
20
21 opencart:
22 image: bitnami/opencart:latest
23 ports:
24 - "80:8080"
25 - "443:8443"
26 environment:
27 - OPENCART_DATABASE_HOST=mysql
28 - OPENCART_DATABASE_NAME=opencart
29 - OPENCART_DATABASE_USER=opencart
30 - OPENCART_DATABASE_PASSWORD=${MYSQL_PASSWORD}
31 - OPENCART_USERNAME=${OPENCART_USER}
32 - OPENCART_PASSWORD=${OPENCART_PASSWORD}
33 - OPENCART_EMAIL=${OPENCART_EMAIL}
34 volumes:
35 - opencart_data:/bitnami/opencart
36 depends_on:
37 - mysql
38 networks:
39 - opencart_net
40
41 phpmyadmin:
42 image: phpmyadmin:latest
43 ports:
44 - "8081:80"
45 environment:
46 - PMA_HOST=mysql
47 depends_on:
48 - mysql
49 networks:
50 - opencart_net
51
52volumes:
53 mysql_data:
54 redis_data:
55 opencart_data:
56
57networks:
58 opencart_net:

.env Template

.env
1# OpenCart
2MYSQL_PASSWORD=secure_mysql_password
3MYSQL_ROOT_PASSWORD=secure_root_password
4OPENCART_USER=admin
5OPENCART_PASSWORD=secure_admin_password
6OPENCART_EMAIL=admin@example.com
7
8# Shop at http://localhost
9# Admin at http://localhost/admin

Usage Notes

  1. 1Shop at http://localhost
  2. 2Admin at http://localhost/admin
  3. 3Lightweight and fast
  4. 4Large extension marketplace
  5. 5Easy to customize themes

Individual Services(4 services)

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

mysql
mysql:
  image: mysql:8.0
  environment:
    - MYSQL_DATABASE=opencart
    - MYSQL_USER=opencart
    - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
  volumes:
    - mysql_data:/var/lib/mysql
  networks:
    - opencart_net
redis
redis:
  image: redis:7-alpine
  volumes:
    - redis_data:/data
  networks:
    - opencart_net
opencart
opencart:
  image: bitnami/opencart:latest
  ports:
    - "80:8080"
    - "443:8443"
  environment:
    - OPENCART_DATABASE_HOST=mysql
    - OPENCART_DATABASE_NAME=opencart
    - OPENCART_DATABASE_USER=opencart
    - OPENCART_DATABASE_PASSWORD=${MYSQL_PASSWORD}
    - OPENCART_USERNAME=${OPENCART_USER}
    - OPENCART_PASSWORD=${OPENCART_PASSWORD}
    - OPENCART_EMAIL=${OPENCART_EMAIL}
  volumes:
    - opencart_data:/bitnami/opencart
  depends_on:
    - mysql
  networks:
    - opencart_net
phpmyadmin
phpmyadmin:
  image: phpmyadmin:latest
  ports:
    - "8081:80"
  environment:
    - PMA_HOST=mysql
  depends_on:
    - mysql
  networks:
    - opencart_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=opencart
8 - MYSQL_USER=opencart
9 - MYSQL_PASSWORD=${MYSQL_PASSWORD}
10 - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
11 volumes:
12 - mysql_data:/var/lib/mysql
13 networks:
14 - opencart_net
15
16 redis:
17 image: redis:7-alpine
18 volumes:
19 - redis_data:/data
20 networks:
21 - opencart_net
22
23 opencart:
24 image: bitnami/opencart:latest
25 ports:
26 - "80:8080"
27 - "443:8443"
28 environment:
29 - OPENCART_DATABASE_HOST=mysql
30 - OPENCART_DATABASE_NAME=opencart
31 - OPENCART_DATABASE_USER=opencart
32 - OPENCART_DATABASE_PASSWORD=${MYSQL_PASSWORD}
33 - OPENCART_USERNAME=${OPENCART_USER}
34 - OPENCART_PASSWORD=${OPENCART_PASSWORD}
35 - OPENCART_EMAIL=${OPENCART_EMAIL}
36 volumes:
37 - opencart_data:/bitnami/opencart
38 depends_on:
39 - mysql
40 networks:
41 - opencart_net
42
43 phpmyadmin:
44 image: phpmyadmin:latest
45 ports:
46 - "8081:80"
47 environment:
48 - PMA_HOST=mysql
49 depends_on:
50 - mysql
51 networks:
52 - opencart_net
53
54volumes:
55 mysql_data:
56 redis_data:
57 opencart_data:
58
59networks:
60 opencart_net:
61EOF
62
63# 2. Create the .env file
64cat > .env << 'EOF'
65# OpenCart
66MYSQL_PASSWORD=secure_mysql_password
67MYSQL_ROOT_PASSWORD=secure_root_password
68OPENCART_USER=admin
69OPENCART_PASSWORD=secure_admin_password
70OPENCART_EMAIL=admin@example.com
71
72# Shop at http://localhost
73# Admin at http://localhost/admin
74EOF
75
76# 3. Start the services
77docker compose up -d
78
79# 4. View logs
80docker 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/opencart-complete/run | bash

Troubleshooting

  • OpenCart installation wizard loops endlessly: Ensure OPENCART_DATABASE_PASSWORD matches MYSQL_PASSWORD in environment variables
  • Shopping cart sessions not persisting: Verify Redis container is running and accessible on opencart_net network
  • Database connection failed error: Wait 30-60 seconds after startup for MySQL to fully initialize before OpenCart connects
  • phpMyAdmin shows 'Connection refused': Check that MySQL container is healthy and PMA_HOST points to 'mysql' service name
  • OpenCart admin panel returns 404 errors: Ensure /bitnami/opencart volume has proper write permissions for web server
  • Product images not displaying: Verify opencart_data volume mount and check image directory permissions in container logs

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