Edit the .env
file to change the default IP address, MySQL root password and WordPress database name.
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 dumpswp-app
– the location of your WordPress application
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
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/:/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/:/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: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