Engineering

⌘K
  1. Home
  2. Docs
  3. Engineering
  4. WordPress
  5. Local WordPress/WooCommerce Development using Docker and Docker Compose

Local WordPress/WooCommerce Development using Docker and Docker Compose

Install Docker.io and Docker Compose:

sudo apt install docker.io docker-compose

References:

Create a new folder for your WordPress/WooCommerce local development project.

Create docker-compose.yml for mariadb (use same version as AWS RDS MariaDB) and wordpress services:

---
version: '3.3'
services:
  db:
    container_name: 'local-wordpress-db'
    image: 'mariadb:10.4'
    volumes:
      - './data/mysql:/var/lib/mysql'
    ports:
      - 18766:3306
    environment:
      MYSQL_ROOT_PASSWORD: somewordpress
      MYSQL_DATABASE: wordpress_db
      MYSQL_USER: wordpress_user
      MYSQL_PASSWORD: wordpress_password

  wordpress:
    container_name: 'local-wordpress'
    depends_on:
      - db
    image: 'wordpress:latest'
    ports:
      - '80:80'
    environment:
      WORDPRESS_DB_HOST: 'db:3306'
      WORDPRESS_DB_USER: wordpress_user
      WORDPRESS_DB_PASSWORD: wordpress_password
      WORDPRESS_DB_NAME: wordpress_db
    volumes:
      - "./wordpress:/var/www/html"
      - "./plugins:/var/www/html/wp-content/plugins"

Start the containers:

docker-compose up

Go to http://localhost/ and you’ll see WordPress installation screen.

Simple Plugin

In plugins/ folder, create a new folder “hello-wordpress” then create “hello-wordpress.php” there for simple plugin:

<?php
/*
  Plugin Name: Hello WordPress
  Plugin URI: http://wordpress.org/plugins/hello-wordpress/
  Description: Hello WordPress!
  Author: John Doe
  Version: 1.0.0
  Author URI: http://example.org/
*/

In WordPress, go to Plugins list and now you should see “Hello WordPress” there.

How can we help?