To set up WordPress and MySQL in no time and without installing them, here is a useful docker-compose.yml file. If you’re new to WordPress development, you’d probably installed XAMPP and MySQL on your Windows machine. You may not want to do it if you’re going to keep your operating system in tiptop condition. Changes are the configuration you do for XAMPP, and MySQL may harm the operating system. Also, you may not want these servers running when you don’t need them.
WordPress And MySQL Images
docker-compose.yml File For Docker Compose
The following is a docker-compose.yml file for our Docker Compose. Note we are making the WordPress files available for modification by placing them in a local directory (line 31).
Make sure the wp_dir folder exists, and Docker File Sharing enabled before moving on.
To use this with Docker Compose, run the following commands in the same directory where the docker-compose.yml file is. Docker Compose will download the WordPress and MySQL images and start them (containers) up.
The following is the output on the command-line window:
When you close the command-line window, you also terminate both WordPress and MySQL containers. If you don’t want that, use the -d option. For example:
docker-compose up -d
If you check out the C:\wp_dir folder, you’d see all the WordPress files.
Testing WordPress With MySQL
Go to http://localhost:8000 and follow the WordPress installation process. To access MySQL from Windows, use the port 3306, as stated in the docker-compose.yml file.
This post is part of the Docker For Developers tutorial.