This repository provides a Docker Compose file to quickly set up a local development environment for WordPress and MySQL. It is designed for developers and designers to test ideas, build sites, or stage projects before migrating to a live instance.
Note: While this setup can be used for self-hosting, it is primarily intended as a temporary solution for development purposes.
To use this repository, you’ll need Docker and Docker Compose. Follow these steps:
- Go to the Docker Desktop download page.
- Download and install Docker Desktop for your operating system (Windows, macOS, or Linux).
- Follow the installation instructions provided by Docker.
- Open a terminal or command prompt.
- Run the following commands to ensure Docker and Docker Compose are installed:
Both commands should return version information.
docker --version docker compose version
- Open your terminal or command prompt.
- Run the following command to clone this repository:
git clone https://github.com/306consultants/wordpress-mysql-compose.git
- Navigate into the repository folder:
cd your-repo-name
Run the following command to start the WordPress and MySQL containers:
docker compose up -d
This command will:
- Download the necessary images (WordPress and MySQL) if they are not already on your system.
- Start the containers in detached mode (
-d
).
- Open a web browser.
- Navigate to
http://localhost:8080/wp-admin
. - You should see the WordPress setup page.
If you want to run more than one instance of WordPress:
- Edit the
docker-compose.yml
file before starting a new instance. - Change the
ports
section under the WordPress service:ports: - "8081:80" # Example for a second instance
- Save the file and run:
docker compose up -d
Important: Make sure not to run multiple containers using the same port (e.g., 8080:80
). If you don't edit the port, start only one instance at a time.
To stop the running containers:
docker compose down
This will stop and remove the containers, but your data (WordPress content and MySQL database) will be preserved in the Docker volumes defined in the docker-compose.yml
file.
If you want to completely remove the containers and data:
- Stop the containers:
docker compose down
- Remove the associated volumes:
docker volume rm your-repo-name_db_data your-repo-name_wordpress_data
-
Can’t access WordPress? Ensure Docker Desktop is running and check for errors in the terminal.
-
Port conflict? Make sure no other services or containers are using port
8080
. Change the port in thedocker-compose.yml
file if needed.
Contributions are welcome! If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.
Happy developing!