Git Product home page Git Product logo

wordpress-docker-compose's Introduction

WPDC - Wordpress Docker Compose

Easy Wordpress development with Docker and Docker Compose

Starting a new project

Make sure you have the latest versions of Docker and Docker Compose installed on your machine. Copy the files from this repository into a blank folder. In the docker-compose.yml file you may change the IP address (in case you run multiple containers) or the database from mysql to mariadb.

Make sure to add your user to the docker group when using linux: https://docs.docker.com/install/linux/linux-postinstall/#manage-docker-as-a-non-root-user

Create containers

Open a terminal and cd to the folder you have the docker-compose.yml and run:

docker-compose up

This create 2 new folders beside your docker-compose.yml file.

  • wp-data - used to store and restore database dumps
  • wp-app - the location of your Wordpress application

The containers are now build and running. You should be able to access the Wordpress installation with the configured IP in the browser address. For convenience you may add a new entry into your hosts file.

Starting containers

You can start the containers with the up command in daemon mode (by adding -d as a param) or by using the start command:

docker-compose start
Stopping containers
docker-compose stop
Remove containers

To stop and remove all the containers use the down command

docker-compose down

Use -v if you need to remove the database volume which is used to persist the database:

docker-compose down -v

Project from existing source

Copy the docker-compose.yml file into a new directory. In the directory you create two folders:

  • wp-data - here you add the database dump
  • wp-app - here you copy your existing wordpress code

You can now use the up command:

docker-compose up

This will create the containers and populate the database with the given dump. You may set your host entry and change it in the database, or you simply overwrite it in the wp-config.php by adding

define('WP_HOME','http://wp-app.local');
define('WP_SITEURL','http://wp-app.local');

Creating database dumps

./export.sh

Developing a Theme

Configure the volume to load the theme in the container in the docker-compose.yml

volumes:
  - ./theme-name/trunk/:/var/www/html/wp-content/themes/theme-name

Developing a Plugin

Configure the volume to load the plugin in the container in the docker-compose.yml

volumes:
  - ./plugin-name/trunk/:/var/www/html/wp-content/plugins/plugin-name

WP CLI

The docker compose configuration also provides a service for using the Wordpress CLI.

Sample command:

docker-compose run --rm wpcli plugin list

For an easier usage you may consider adding an alias for the CLI:

alias wp="docker-compose run --rm wpcli"

This way you can use the CLI command above as follows:

wp plugin list

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.