<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Tunerlabs Dev</title>
    <description>The latest articles on DEV Community by Tunerlabs Dev (@tunerlabs_dev).</description>
    <link>https://dev.to/tunerlabs_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2946846%2F0104b168-5e5b-4a07-82bb-2bfb2042b897.jpg</url>
      <title>DEV Community: Tunerlabs Dev</title>
      <link>https://dev.to/tunerlabs_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tunerlabs_dev"/>
    <language>en</language>
    <item>
      <title>Open Cart Setup in docker using Postgres as database</title>
      <dc:creator>Tunerlabs Dev</dc:creator>
      <pubDate>Fri, 04 Apr 2025 00:09:59 +0000</pubDate>
      <link>https://dev.to/tunerlabs_dev/open-cart-setup-in-docker-using-postgres-as-database-1id5</link>
      <guid>https://dev.to/tunerlabs_dev/open-cart-setup-in-docker-using-postgres-as-database-1id5</guid>
      <description>&lt;h1&gt;
  
  
  OpenCart Docker Setup Guide
&lt;/h1&gt;

&lt;p&gt;This guide will help you set up OpenCart using Docker and Docker Compose.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Docker installed on your system&lt;/li&gt;
&lt;li&gt;Docker Compose installed on your system&lt;/li&gt;
&lt;li&gt;Basic understanding of Docker concepts&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Setup Instructions
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Create a new directory for your OpenCart project&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   &lt;span class="nb"&gt;mkdir &lt;/span&gt;opencart-docker
   &lt;span class="nb"&gt;cd &lt;/span&gt;opencart-docker
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Save the docker-compose.yml file&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Create a file named &lt;code&gt;docker-compose.yml&lt;/code&gt; and paste the content from the Docker Compose configuration provided.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Customize environment variables (Optional)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Before running the containers, you might want to modify the environment variables in the docker-compose.yml file:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;OPENCART_HOST&lt;/code&gt;: Set to your domain name or IP address if deploying to production&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OPENCART_USERNAME&lt;/code&gt;: Admin username&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OPENCART_PASSWORD&lt;/code&gt;: Admin password&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OPENCART_EMAIL&lt;/code&gt;: Admin email&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MARIADB_USER&lt;/code&gt;: Database username&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MARIADB_PASSWORD&lt;/code&gt;: Database password&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Start the containers&lt;/strong&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;-d&lt;/code&gt; flag runs the containers in the background (detached mode).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Wait for initialization&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It may take a minute or two for OpenCart to fully initialize. You can check the logs with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker-compose logs &lt;span class="nt"&gt;-f&lt;/span&gt; opencart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;Access OpenCart&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Frontend: &lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Admin panel: &lt;a href="http://localhost:8080/admin" rel="noopener noreferrer"&gt;http://localhost:8080/admin&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Login with the username and password you set in the environment variables&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Volume Information
&lt;/h2&gt;

&lt;p&gt;The setup uses Docker volumes to persist data:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;opencart_data&lt;/code&gt;: Stores OpenCart files and configurations&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;postgres_data&lt;/code&gt;: Stores the PostgreSQL database files&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Managing Your OpenCart Installation
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Stopping the containers
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose down
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Stopping and removing volumes (will erase all data)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose down &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Updating to a newer version
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Pull the latest images:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker-compose pull
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Restart the containers:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;   docker-compose down
   docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Security Considerations for Production
&lt;/h2&gt;

&lt;p&gt;For a production environment, consider:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Using secure passwords&lt;/strong&gt;: Change all default passwords in the docker-compose.yml file&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Setting up HTTPS&lt;/strong&gt;: Either through a reverse proxy or by configuring the SSL settings&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Regular backups&lt;/strong&gt;: Set up a backup strategy for your volumes&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Network isolation&lt;/strong&gt;: Customize the network configuration for better security&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Troubleshooting
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Database connection issues
&lt;/h3&gt;

&lt;p&gt;If OpenCart cannot connect to the database, ensure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The MariaDB container is running (&lt;code&gt;docker-compose ps&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;The environment variables are correctly set&lt;/li&gt;
&lt;li&gt;The network is properly configured&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Permission issues
&lt;/h3&gt;

&lt;p&gt;If you encounter permission issues with the volumes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose down
&lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="nt"&gt;-R&lt;/span&gt; 1001:1001 ./path/to/your/volumes
docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Logs
&lt;/h3&gt;

&lt;p&gt;Check the logs for any issues:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker-compose logs opencart
docker-compose logs postgres
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
