Easy setup local WordPress development enviroment with Docker and Docker Compose.
With this project you can quickly run the following:
Make sure you have the latest versions of Docker and Docker Compose installed on your machine.
MacOS:
Install Docker, Docker-compose and Docker-sync.
Windows:
Install Docker, Docker-compose and Docker-sync.
Linux:
Install Docker and Docker-compose.
Make sure to add your user to the docker
group when using Linux.
Execute in your terminal, change the WPFOLDER to use the name of your project:
git clone https://github.com/baracatuemura/wordpress-docker-compose.git WPFOLDER
cd WPFOLDER
cp env.example .env
./start
cp -R wp-app/wp-content/themes/ src/
cp -R wp-app/wp-content/plugins/ src/
In browser go to http://127.0.0.1
cd WPFOLDER
cp env.example .env
mkdir wp-data
- copy the database dump to
wp-data
folder - copy
themes
,plugins
anduploads
folders tosrc
folder
./start
docker-compose run --rm wpcli search-replace 'http://mysite.com' 'http://127.0.0.1'
In browser go to http://127.0.0.1
Copy the example environment into .env
cp env.example .env
Edit the .env
file to change the default IP address, MySQL root password and WordPress database name.
You can start the containers with the up
command in daemon mode (by adding -d
as an argument) or by using the start
command:
./start
or
docker-compose up
or
docker-compose start
./stop
or
docker-compose stop
To stop and remove all the containers use thedown
command:
docker-compose down
To Stops containers and removes containers, networks, volumes, and images created to the specific project
./kill
or
docker-compose down -v
./export.sh
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
Or to search-replace:
docker-compose run --rm wpcli search-replace 'http://mysite.com' 'http://wp-app.local'
Create new admin user
docker-compose run --rm wpcli user create baracat [email protected] --role=administrator --user_pass=newpass
alias wp="docker-compose run --rm wpcli"
This way you can use the CLI command above as follows:
wp plugin list
You can also visit http://127.0.0.1:8080
to access phpMyAdmin after starting the containers.
The default username is root
, and the password is the same as supplied in the .env
file.
This project is based in Harald Nezbeda docker environment: https://github.com/nezhar/wordpress-docker-compose