OpenCart Docker Setup Guide
This guide will help you set up OpenCart using Docker and Docker Compose.
Prerequisites
- Docker installed on your system
- Docker Compose installed on your system
- Basic understanding of Docker concepts
Setup Instructions
- Create a new directory for your OpenCart project
mkdir opencart-docker cd opencart-docker
- Save the docker-compose.yml file Create a file named
docker-compose.yml
and paste the content from the Docker Compose configuration provided. - Customize environment variables (Optional) Before running the containers, you might want to modify the environment variables in the docker-compose.yml file:
OPENCART_HOST
: Set to your domain name or IP address if deploying to productionOPENCART_USERNAME
: Admin usernameOPENCART_PASSWORD
: Admin passwordOPENCART_EMAIL
: Admin emailMARIADB_USER
: Database usernameMARIADB_PASSWORD
: Database password
- Start the containers
docker-compose up -d
The-d
flag runs the containers in the background (detached mode). - Wait for initialization It may take a minute or two for OpenCart to fully initialize. You can check the logs with:
docker-compose logs -f opencart
- Access OpenCart
- Frontend: http://localhost:8080
- Admin panel: http://localhost:8080/admin
- Login with the username and password you set in the environment variables
Volume Information
The setup uses Docker volumes to persist data:
opencart_data
: Stores OpenCart files and configurationspostgres_data
: Stores the PostgreSQL database files
Managing Your OpenCart Installation
Stopping the containers
docker-compose down
Stopping and removing volumes (will erase all data)
docker-compose down -v
Updating to a newer version
- Pull the latest images:
docker-compose pull
- Restart the containers:
docker-compose down docker-compose up -d
Security Considerations for Production
For a production environment, consider:
- Using secure passwords: Change all default passwords in the docker-compose.yml file
- Setting up HTTPS: Either through a reverse proxy or by configuring the SSL settings
- Regular backups: Set up a backup strategy for your volumes
- Network isolation: Customize the network configuration for better security
Troubleshooting
Database connection issues
If OpenCart cannot connect to the database, ensure:
- The MariaDB container is running (
docker-compose ps
) - The environment variables are correctly set
- The network is properly configured
Permission issues
If you encounter permission issues with the volumes:
docker-compose down sudo chown -R 1001:1001 ./path/to/your/volumes docker-compose up -d
Logs
Check the logs for any issues:
docker-compose logs opencart docker-compose logs postgres