How To Run Wordpress In Docker | Hacker Noon

Ben Force Hacker Noon profile picture

Been making things with code since I was 8. Probably an addict at this point.

I use a package manager called chocolatey to install/uninstall software when I can. If you have chocolatey setup, just run the following command to install docker:

choco install docker-desktop

Kitematic provides a visual interface to docker, so if you don't care much for the command line, I'd recommend installing that as well:

choco install docker-kitematic

Starting Docker

After the installation has finished, log out then back in. Run docker desktop by pressing the Windows key and searching for docker desktop. Once docker is ready, you'll see the icon in the system tray stop animating and a login window will appear.

The last step is to make sure Docker is working. Open a new PowerShell window and run the following command:

You should see output indicating that Docker is running.

Run WordPress in Docker

Now that Docker is set up on your system we can start WordPress. Since WordPress requires an instance of MySql running to store all of its data, we need to run two containers and connect them. We'll also want their data to persist if we stop the containers and restart them later. To accomplish this we create a docker-compose file, with volumes for each container.

Save the following file as 


version: "3.3" services:
 image: mysql:5.7
 - db_data:/var/lib/mysql
 - "3306:3306"
 restart: always
 MYSQL_ROOT_PASSWORD: somewordpress
 MYSQL_DATABASE: wordpress
 MYSQL_USER: wordpress
 MYSQL_PASSWORD: wordpress  wordpress:
 - db
 image: wordpress:latest
 - wordpress:/var/www/html
 - "8000:80"
 restart: always
 db_data: {}
 wordpress: {}

Open a shell in the directory where you saved the docker-compose file and run 

docker-compose up -d
. After a few minutes, you'll have WordPress running on your machine.

Running WordPress Install

Before you can start writing plugins for WordPress, you need to run through the setup pages on your new server. Browse to http://localhost:8000/wp-admin/install.php and follow the instructions.

Creating a Plug-in

To create a plugin, you need to add a folder in WordPress' 

 directory. To find the root directory, open kitematic by clicking on the docker icon in the system tray and selecting 
 from the menu.

Now select the WordPress container on the left side of the window, and click 

 under the list of volumes on the right side.

This will open Windows Explorer with the 

 folder selected. Open it, then browse to 
. Create a new folder called first-plugin then open it. Create a file called 
 inside the new folder and paste the following code into it:

* Plugin Name: First Plugin
* Plugin URI:
* Description: Your very first plugin!
* Version: 1.0
* Author: Ben Force
* Author URI:
* License: GPLv2 or later

Save the file and browse to http://localhost:8000/wp-admin/plugins.php, you should your plugin in the list.

I hope this tutorial has given you a good starting point that's easier than installing a PHP server and MySQL. Let me know if you have any suggestions or questions.

Join Hacker Noon

Create your free account to unlock your custom reading experience.