This will create a container stack by the same name as the folder it sits in. Change project name in .env
project=kundenname
at the top and change "kundenname" to something descriptive.
Dockerfile that pulls wordpress-apache and sets a couple of neccesary PHP ini-files and enables xdebug.
creates two containers wp
(with the Dockerfile) and db
for a standard MariaDB in a stack named earlier. The root of the Apache html
and the database data are bound to subfolders app
to db
respectively. The website can be accessed by
- localhost:8080/ →
./app
aswp-content
folder - The rest of WordPress is irrelevant
First start Docker Desktop. When you're ready, start your application by running:
docker compose up --build
.
in a terminal. If you have the Docker VSCode Extention installed it is even simpler. Open the compose.yaml
and click
After this check the running state of the container in Docker Desktop.
If Docker Desktop or the docker daemon is not running you will see a confusing message:
If that happens start Docker Desktop and try again.
Setting up the database might take some time on slower hardware. Make sure that activity in the docker has died down.
Two extension are super handy:
- Container Tools (previous Docker)
- SQL-Tools for direct database access
- PHP Profiler, to test what took so long
- PHP Debug, to troubleshoot and step debug
The last two are only needed if one does theme or plugin development. Debugging / Profiling also needs a browser xdebug plugin. Watch the /logs
folder for apache and xdebug logs. Make sure to set the proper setting in xdebug.ini
and reboot the web server. Also check the section on launch.json
Normally you won't need database access from outside so the db
server is not bridged. If you do need access add a port mapping in the db service and restart the container.
- Install xdebug extension
- create launch.json (open the xdebug tab and click "create a launch.json file" )
- click the gear icon and add this to the configurations section in
launch.json
file (for instance directly below the"port": 9003,
line)
"pathMappings": {
"/var/www/html": "${workspaceFolder}/app"
}
and save the file. This assumes you have your webroot in a folder app as indicated above.
As all key ingredients sit on in the file system, moving or copying the project is easy. Zip the project including app
and db
folders and unzip it somewhere else;. Make sure in Docker Desktop to shutdown the database first.