Quickstart: Compose and WordPress
You can use Docker Compose to easily run WordPress in an isolated environment built with Docker containers. This quick-start guide demonstrates how to use Compose to set up and run WordPress. Before starting, make sure you have Compose installed.
Define the project🔗
- Create an empty project directory.
You can name the directory something easy for you to remember. This directory is the context for your application image. The directory should only contain resources to build that image.
This project directory contains adocker-compose.yml
file which is complete in itself for a good starter wordpress project.
Tip: You can use either a
.yml
or .yaml
extension for this file. They both work.
2. Change into your project directory. For example, if you named your directory my_wordpress
:
3.Create a docker-compose.yml
file that starts your WordPress
blog and a separate MySQL
instance with a volume mount for data persistence:
Build the project🔗
Now, run docker-compose up -d
from your project directory.
This runs docker-compose up in detached mode, pulls the needed Docker images, and starts the wordpress and database containers, as shown in the example below.
Bring up WordPress in a web browser🔗
At this point, WordPress should be running on port 8000
of your Docker Host, and you can complete the “famous five-minute installation” as a WordPress administrator.
Note: The WordPress site is not immediately available on port
8000
because the containers are still being initialized and may take a couple of minutes before the first load.
Shutdown and cleanup🔗
The command docker-compose down removes the containers and default network, but preserves your WordPress database.
The command docker-compose down --volumes
removes the containers, default network, and the WordPress database.