Get Started with a Local WordPress Setup Using Docker

Updated on:

Every local website requires a robust environment to function optimally. This generally involves configuring a web server, setting up a database, and ensuring support for all necessary programming languages. Installing and integrating these components can be complex and challenging. That’s why local WordPress development with Docker is a game-changer.

Docker is an innovative application that allows you to create complete, self-contained environments with just a few commands. It’s fully compatible with WordPress and is incredibly useful for setting up various local environments with different web servers or tools. Each Docker container operates like a virtual machine, giving you the flexibility to configure different technology stacks as needed.

In this article, we’ll dive into the benefits of using Docker for local WordPress plugin and theme development on Windows 11. We’ll then guide you through the setup process in three straightforward steps!


The following techniques and tools will be utilized in this article:

  • OS Windows 11
  • Notepad++
  • Windows Command shell
  • Docker Desktop
  • YAML configuration file

What makes Docker ideal for local WordPress development?

Creating a local WordPress environment usually involves installing an entire stack at once. Once set up, changing components can be a hassle. For instance, if you initially choose Apache but later need NGINX, installing it alongside Apache can be complex. Recreating production environments often necessitates such changes.

Docker offers a solution by enabling you to set up isolated ‘containers’ that include complete development environments. Think of it as creating a Virtual Machine (VM) but without the overhead of an operating system. These containers provide almost all the benefits of VMs while using fewer system resources. This means you can set up multiple environments on a single computer effortlessly.

Moreover, Docker allows you to turn containers on or off as needed, minimizing the impact on your system. Restarting a container requires just a single command, making the process seamless.

Key Features of Docker:

  • Create isolated development environments within containers.
  • Use fewer resources compared to traditional VMs.
  • Share containers easily for enhanced collaboration.
  • Containers can run on any system that supports Docker.
  • Allows for fast and consistent deployment of applications

Begin Local WordPress Development with Docker in Just 3 Steps

For an optimal experience with local WordPress development through Docker, a familiarity with the command line is ideal. But don’t fret – even if you’re new to it, simply follow our step-by-step guide, and you’ll be on your way. While a deep understanding of the command line offers flexibility, our instructions will ensure you start on solid ground.

This tutorial utilizes the Windows version of Docker, though it’s equally accessible on Mac and Linux. The beauty of these commands lies in their cross-platform compatibility, ensuring a uniform process regardless of your OS. So, let’s dive in and unlock the power of Docker for WordPress development!

Step 1: Download and install Docker Desktop

Lets begin your Docker journey by navigating to the Docker Desktop page, where you’ll discover the download button. Here, you can tailor your selection based on your operating system: Windows, Mac or Linux.

The download and installation process is straightforward. Simply navigate through the installation screens and wait for completion. A quick restart of your computer, and you’re almost set.

Go to the Start menu and launch Docker Desktop, select “Containers”, it should show you a list of running Docker containers.

But wait, if it’s empty, don’t fret! We’re about to change that. With a few simple steps, you’ll go from an empty list to a bustling ecosystem of containers, harnessing the full potential of Docker.

Step 2: Craft a WordPress Environment with Docker Container

There’s more than one way to set up a WordPress environment using containers, but we’re going to show you the smart way – a streamlined approach using Compose, a tool bundled with Docker Desktop. With Compose you can orchestrate all the services your container needs in one swift motion.

Open your command line and enter the following:

> mkdir docker-wordpress
> cd docker-wordpress

These commands create a directory named docker-wordpress and navigate you directly into it. Open this folder and create a new file named .env and docker-compose.yml in your preferred text editor.

The .env file is a powerhouse for managing your project’s configuration settings. Within this file, you can securely store API keys, establish database connections, and define environment-specific configurations, all in one place. By separating these sensitive settings from your code, you gain the flexibility to update and manage them with ease. In our case, we will store MySQL settings such as the database name, users and their corresponding passwords.

The docker-compose.yml file is the primary configuration file that orchestrates the Docker magic. Within this file, you define the necessary images, expose specific ports, grant access to the host filesystem, and instruct containers on their startup commands. It serves as a blueprint, bringing your application stack to life. This file acts as the instruction manual for seamless application deployment and management, making Docker Compose a powerful tool in the hands of developers.

Now, for the magic touch – paste the code snippet below into the files and get ready to unleash the power of WordPress with Docker.

    image: wordpress
    restart: unless-stopped
      - 8080:80
    env_file: .env
      - ./wp-content:/var/www/html/wp-content

    image: mysql
    restart: unless-stopped
      - 3306:3306
    env_file: .env
      - db-data:/var/lib/mysql

MYSQL_DATABASE = wordpress
MYSQL_USER = wp_user
MYSQL_PASSWORD = wp_password
MYSQL_ROOT_PASSWORD = root_password


If you wish, you can personalize the value of the variables in the .env file. After making your changes, save and exit the editor. With these simple steps, you have indicated to Docker that it needs to create a new MySQL database for WordPress, install the core software, and organize the necessary support services.

In our docker-compose.yml file we have defined only the ./wp-content directory, this folder will be accessible directly in the Windows file system. This direct access will come in handy later on when developing plugins or themes for WordPress.

Typically this directory discover three essential folders: plugins, themes, and uploads. Each holds a specific purpose in the WordPress ecosystem:

  • Plugins Directory: As the name suggests, this directory is the designated home for WordPress plugins. When you install a plugin through the user-friendly plugin menu, it seamlessly finds its place here. Conversely, you can also manually install plugins by extracting and copying them into this very directory.
  • Themes Directory: Much like its counterpart, the themes folder, houses all your WordPress themes. Whether you install a theme from the backend or prefer to manually copy themes into this directory, they will reside here. This folder becomes your go-to destination when crafting or modifying your unique theme or creating a child theme.
  • Uploads Directory: The uploads folder is where WordPress meticulously organizes your media files, including images, videos, and various other uploaded content. By default, media files are intelligently sorted into subfolders, each representing the year and month of their addition to your site. However, you also have the flexibility to disable this feature, resulting in all files conveniently landing in the same directory.

So, this is the standard WordPress layout within the wp-content directory. However, as your site matures and evolves, you may encounter additional folders nestled within wp-content, each serving specific functions and contributing to the overall customization and functionality of your WordPress site.

Step 3: Launch your WordPress site with Docker

Now, it’s time to ask Docker to initiate your container. To interact with Docker and manage containers, you need to have Docker Desktop running on your Windows system. So, before executing the command to navigate to the directory, ensuring that Docker Desktop is open and running is essential:

> cd docker-wordpress

Once you’re in the right directory, it should contain our .env and docker-compose.yml files, execute the following command to get things rolling:

> docker compose up -d

Take a breather as Docker downloads and configures all the services specified in your meticulously crafted docker-compose.yml file. The time this process takes can vary, depending on the speed of your internet connection.

Once Docker works its magic, your WordPress site will be accessible from any browser by simply entering the ports you configured. For instance, if you set up ports 8080 and localhost, you’d access your site like this:


Completing your local WordPress setup with ease

From here on out, all you need to do is follow the standard WordPress setup procedure in your browser. It’s as simple as that!

The WordPress container you created will be visible in Docker Desktop, giving you a clear overview:

The beauty of Docker is that you’re not limited to a single container. Feel free to create as many containers as your heart desires.

Now, you’re fully equipped to dive into local WordPress development, backed by the efficiency and flexibility of Docker. So, go ahead and let your creativity flow!


Docker is an effective containerization solution, optimizing the development process for content management systems such as WordPress. Its lightweight environment ensures your system resources remain efficient and performant.