WordPress Plugin Development with Docker and Visual Studio Code

My preferred way of dong WordPress Plugin Development is by using Docker. Specifically, I use the wordpress and mariadb Docker images.

An example docker-compose.yml is as follows:

version: '3.7'

services:

  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - ./wordpress:/var/www/html
      - ./container-loading:/var/www/html/wp-content/plugins/container-loading

  db:
    image: mariadb
    restart: always
    environment:
      MYSQL_DATABASE: exampledb
      MYSQL_USER: exampleuser
      MYSQL_PASSWORD: examplepass
      MYSQL_RANDOM_ROOT_PASSWORD: '1'
    volumes:
      - db:/var/lib/mysql

volumes:
  # wordpress:
  db:

By mounting plugin directory here:

  - ./container-loading:/var/www/html/wp-content/plugins/container-loading

I can work with the plugin using Visual Studio code and the plugin is automatically accessible within the WordPress container.

To start WordPress with the configuration, I do:

docker-compose up -d
0

Leave a Comment

Your email address will not be published. Required fields are marked *