This template provides:
- WordPress container (the version of wordpress can be changed)
- MySQL container (the version of mysql can be changed)
- Mail container to catch all emails WordPress sends
- xdebug extension and bookmarks to enable / disable debugging
- /cdn-bin/ scripts to update site url in the whole database
Checklist:
- clone / download this repo: https://github.com/help-me-mom/wordpress-docker-template
- remove the line with
/website/src
from.gitignore
- if needed, update mysql version in
compose.yml
inservices > databse > image
by default the latest one is used - if needed, update wordpress version in
website/docker.dev/Dockerfile
inFROM
by default the latest one is used - you might want to use a different hostname than
localhost
, becauselocalhost
won't let you send emails
for example, you can add127.0.0.1 wp.internal
to/etc/hosts
orC:\Windows\System32\drivers\etc\hosts
file - you can execute
docker compose up --build
to build and start containers
you might need to wait until containers finish their bootstrap: creating databases, downloading WP, etc. - open http://wp.internal/ to finish WP installations
- open http://localhost:81/ to verify you got an email about a new WordPress Website
- that's it, now you can commit changes to git and start development
Checklist:
- ensure you have source files of the existing project
- ensure you have a database dump of the existing project
- clone / download this repo: https://github.com/help-me-mom/wordpress-docker-template
- remove the line with
/website/src
from/.gitignore
- update mysql version in
/compose.yml
inservices > databse > image
you should use the same version as in the existing project - update wordpress version in
/website/docker.dev/Dockerfile
inFROM
you should use the same version as in the existing project - you might want to use a different hostname than
localhost
, becauselocalhost
won't let you send emails
for example, you can add127.0.0.1 wp.internal
to/etc/hosts
orC:\Windows\System32\drivers\etc\hosts
file - copy files from the existing project into
/website/src
- update
wp-config.php
to respect local database connection
if you have definedDB_NAME
,DB_USER
,DB_HOST
, etc, you need wrap them with an if-else block:if (getenv('WORDPRESS_DB_HOST')) { define('DB_HOST', getenv('WORDPRESS_DB_HOST')); define('DB_USER', getenv('WORDPRESS_DB_USER')); define('DB_PASSWORD', getenv('WORDPRESS_DB_PASSWORD')); define('DB_NAME', getenv('WORDPRESS_DB_NAME')); define('DB_CHARSET', getenv('WORDPRESS_DB_CHARSET')); define('WP_DEBUG', getenv('WORDPRESS_DEBUG')); } else { // here you need to place existing definitions of the contants above }
- you can execute
docker compose up --build
to build and start containers
you might need to wait until containers finish their bootstrap: creating databases, etc. - import the database dump: instructions how to import a database
- replace domain name in the database: http://wp.internal/cgi-bin/
- open http://wp.internal/ to verify website works locally as expected
- that's it, now you can commit changes to git and start development
To export the database from docker, you need to execute the next command:
docker compose exec -T database mysqldump -uroot website --routines > website.sql
To import a database into docker, you need to execute the next command,
where website.sql
should be the file you want to import:
docker compose exec -T database mysql -uroot website < website.sql
Emails can be checked at http://localhost:81/
TBD
TBD