Setting up WooCommerce with Docker using this Docker Compose

Tiempo de lectura: 2 minutos

Hello, today we are going to learn how to set up a WooCommerce store using WordPress directly with Docker Compose.

In today’s e-commerce landscape, having a solid and versatile platform is essential for the success of any online business. WordPress and WooCommerce have become a powerful combination for creating attractive and functional online stores. If you’re looking for an efficient and isolated way to deploy WordPress and WooCommerce in your development environment, Docker is the solution you’re looking for.

Docker has revolutionized the way we build, deploy, and manage applications. It provides lightweight and portable containers that encapsulate all the necessary dependencies to run an application consistently in any environment. In this article, we will explore the steps to install WooCommerce alongside WordPress using Docker, allowing you to have a flexible and isolated development environment without worrying about dependency conflicts or complicated configurations.

Below, I have set up the following environment in a Docker Compose file:

version: "3.1"
services:
  miservicio_mariadb_wp_woocommerce:
    image: mariadb
    restart: unless-stopped
    container_name: miservicio_mariadb_wp_woocommerce
    environment:
      MYSQL_ROOT_PASSWORD: passWordRoot
      MYSQL_DATABASE: WordPress
    volumes:
      - ./config/mariadb:/var/lib/mysql
    ports:
      - 3306:3306
    networks:
      - docker-network

  phpmyadmin_wp_woocomerce:
    image: phpmyadmin
    restart: unless-stopped
    container_name: phpmyadmin_container_wp_woocomcerce
    ports:
      - 8080:80
    environment:
      - PMA_ARBITRARY=1
    links:
      - miservicio_mariadb_wp_woocommerce:db
    networks:
      - docker-network

  wordpress_woocommerce:
    image: wordpress
    restart: always
    container_name: wordpress_woocommerce
    environment:
      WORDPRESS_DB_HOST: miservicio_mariadb_wp_woocommerce
      WORDPRESS_DB_USER: root
      WORDPRESS_DB_PASSWORD: passWordRoot
      WORDPRESS_DB_NAME: WordPress
    volumes:
      - ./www:/var/www/html
      - ./plugins:/var/www/html/wp-content/plugins
    networks:
      - docker-network

networks:
  docker-network:
    driver: bridge
    external: true

In this file, we have deployed a mariadb server, a phpmyadmin for managing the server, and the official WordPress container. We have also specified to use the www path (external folder in our directory) to store Docker files. Additionally, we’ve added the plugins folder where we store WordPress plugins.

Now we can launch it using the following command:

docker compose up -d

With this command, we launch the entire environment.

Once installed, we can start configuring it:

Once you have selected the language, configure the rest of the fields.

Now, configure the site name and other details:

Next, go to “Appearance” and select a theme.

Search for storefront.

Leave a Comment