Skip to main content

Command Palette

Search for a command to run...

Deploying a E-commerce Store Using Docker-Compose

Updated
2 min read
Deploying a E-commerce Store Using Docker-Compose
S

Hi! My name is Safia Khatoon. I am complete my Bachelors in Technology from RTC Institute Of Technology. My specialisation in Computer Science and Engineering.I love contributing to Open Source with the help of the skills I gain.

Also, I'm working on my YouTube Channel as well where I teach about DevOps tools and make technical content. You can have a look at it through my profile.

Feel free to reach out to me! I'd be happy to connect with you.

E-commerce Store: Docker Compose can also be used to create an e-commerce store. You can set up a web server, a database server, and an e-commerce platform like Magento or WooCommerce step by step with example

Magento: is a tool that enables businesses to create an online store where they can sell their products or services. It provides a user-friendly interface that makes it easy for businesses to manage their online store and process orders from customers.

WooCommerce: is a powerful and flexible e-commerce platform that can help you build a successful online store. Whether you're just starting out or looking to upgrade your existing online store, WooCommerce is definitely worth considering.

  1. Create a new directory for your project and create a new file called docker-compose.yml within it.

  2. Add the following code to the docker-compose.yml file

  3. 
      services:
        web:
          image: nginx:latest
          ports:
            - "80:80"
          volumes:
            - ./src:/var/www/html
          depends_on:
            - php
        php:
          image: php:fpm
          volumes:
            - ./src:/var/www/html
          environment:
            - MYSQL_HOST=db
            - MYSQL_USER=root
            - MYSQL_PASSWORD=root
            - MYSQL_DATABASE=magento
          depends_on:
            - db
        db:
          image: mysql:5.7
          volumes:
            - db-data:/var/lib/mysql
          environment:
            - MYSQL_ROOT_PASSWORD=root
            - MYSQL_DATABASE=magento
      volumes:
        db-data:
    

This code defines three services:

  • web: A web server using the Nginx image that maps port 80 on your host machine to port 80 in the container.

  • php: A PHP-FPM image that serves the Magento application.

  • db: A MySQL database server.

  1. Create a new directory called src and add the Magento application files to it.

  2. Start the containers using the following command:

  3.  docker-compose up -d
    

This command will start the containers in detached mode, which means they will run in the background.

  1. Access the Magento application by opening your web browser and navigating to http://localhost. You should see the Magento installation page.

  2. Follow the Magento installation steps, using the following database details:

  • Database host: db

  • Database name: magento

  • Database user: root

  • Database password: root

That's it! You now have a fully functional e-commerce store running in Docker Compose using Magento.

More from this blog

Untitled Publication

136 posts