Easy WordPress development with Docker and Docker Compose.
With this project you can quickly run the following:
Contents:
Make sure you have the latest versions of Docker and Docker Compose installed on your machine.
Make sure to add your user to the docker
group when using Linux.
All the ENVIRONENTS are stored in the .env file that is created through ./create.sh
Open a terminal and run create.sh and enter in environment variables
For convenience you may add a new entry into your hosts file.
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
docker-compose stop
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
./export.sh
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
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
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 --title=test --admin_user=admin [email protected]
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