Skip to content

mfyz/wordpress-docker-compose

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WordPress Docker Compose

Configuration

Edit the .env file to change the default IP address, MySQL root password and WordPress database name.

Installation

Open a terminal and cd to the folder in which docker-compose.yml is saved and run:

docker-compose up -d

This creates two new folders next to your docker-compose.yml file.

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

Usage

Starting containers

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

docker-compose start -d

Stopping containers

docker-compose stop

Removing containers

To stop and remove all the containers use thedown 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

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/:/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/:/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 to install WordPress:

docker-compose run --rm wpcli core install --url=http://localhost:6001 --title=test --admin_user=admin --admin_password=admin --admin_email=test@example.com --skip-email

Or to list installed plugins:

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

About

Easy Wordpress development with Docker and Docker Compose

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%