Using Docker Compose to speed up WordPress development

Last updated on October 21, 2022 A Goodman Loading... One comment

This article is about using Docker Compose to speed up your WordPress development.


In the old days, to set up a WordPress project on our local computer, we used to create a new MySQL database, manually download the WordPress zip file from and unzip it, then walk through a bunch of configuration steps. These days, you can still use that method but there’s a new approach that helps us save a lot of time: using Docker. This approach is currently widely used and at this time, the WordPress image on Docker Hub was downloaded more than 500 million times.

In this tutorial, we’ll create a boilerplate WordPress project that is reusable. With it, you can initialize a new local WordPress with only one command:

docker-compose up

With Docker, you DO NOT need to use XAMPP, WampServer… or manually install PHP, Apache (or Nginx), MySQL on your computer.


You must have Docker Desktop installed and running on your Mac or Windows computer. If not, check out the guides on how to install Docker Desktop for Mac users and Windows users.

Getting Started

1. Create the project folder:

mkdir my_wp

2. Navigate to the project root and create 2 new files docker-compose.yml and uploads.ini as well as an empty folder named wp-content. This folder is where your themes and plugins live in.

├── docker-compose.yml
├── uploads.ini
└── wp-content

3. Add the following to uploads.ini:

file_uploads = On
memory_limit = 128M
upload_max_filesize = 128M
post_max_size = 128M
max_execution_time = 600

4. Add this to docker-compose.yml:

version: "3"
    image: mysql:latest
      - db_data:/var/lib/mysql
      MYSQL_ROOT_PASSWORD: abcd1234 
      MYSQL_USER: admin
      MYSQL_PASSWORD: abcd1234
      MYSQL_DATABASE: wordpress

      - db
    image: wordpress:5.9.0-php7.4-apache
      - "80:80"
      WORDPRESS_DB_HOST: db:3306
      WORDPRESS_DB_USER: admin
      WORDPRESS_DB_NAME: wordpress

    working_dir: /var/www/html

      - ./wp-content:/var/www/html/wp-content
      - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini


How to reuse the boilerplate?

If you have knowledge about Git, just push the my_wp folder with docker-compose.yml, uploads.ini, and wp-content to GitHub, GitLab… and clone it each time you want to start a new project. If you don’t use Git, just copy and paste it somewhere on your computer.

Check It Out

1. Make a new copy of the my_wp folder (to keep the old one clean) and perform this command in the new project root:

docker-compose up

Then you should see some output like this in your console window:

2. Now launch your browser and go to http://localhost:

It works!

Final Words

This tutorial went over the steps of working with Docker compose and WordPress. You can explore more tags and settings on the official WordPress page on Docker Hub.

If you’d like to learn more about Docker and WordPress, take a look at the following articles:

You can also check out our Docker topic page for the latest tutorials, examples, tips, and tricks.

Notify of
1 Comment
Inline Feedbacks
View all comments
18 days ago

Nice post. I learn something totally new and challenging on websites

Related Articles