How to Install WordPress on Docker (Windows)

Dhia Hannachi
2 min readJan 9, 2022

If you are looking for a way to create isolated environments to test your WordPress, then familiarize yourself with container technology. In this article, we’ll cover a step-by-step guide to install WordPress on Docker, the best-known container platform.

If you are looking for a way to create isolated environments to test your WordPress, then familiarize yourself with container technology. In this article, we’ll cover a step-by-step guide to install WordPress on Docker, the best-known container platform.

Here’s how you can install Docker on Windows 10 64-bit:
1. Enable Hyper-V in your system.

2. Download Docker Desktop for Windows and open the Docker for Windows Installer file.

3. In the Configuration dialog window, check or uncheck the boxes based on your preferences. Click Ok.

4. Once the installation is finished, hit Close. You’ll see the Docker icon in the taskbar.

Step 2: Setting-Up WordPress on Docker

Next, let’s set up WordPress on Docker. You can do this process with these two methods ‒ the CLI and Docker compose.

In this article, we’ll be using Docker compose, the cleaner and more systematic method. Here’s how:

  1. Check Docker Compose Installation:
docker-compose --version

2. Create a new directory for WordPress:

mkdir ~/wordpress/
cd ~/wordpress/

3. Create a new docker-compose.yml in the new directory and paste the content below. Don’t forget to change the credentials.

version: '3.3'services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
WORDPRESS_DB_NAME: wordpress
volumes:
db_data: {}

4. Run this command in the directory to create the containers:

docker-compose up -d

5. Your browser will enter localhost:8000 and display the WordPress setup screen.

Conclusion

In this tutorial, you’ve learned how to install Docker on Linux, macOS, and Windows. You’ve also learned how to set up WordPress on Docker using the Docker Compose utility.

--

--

Dhia Hannachi

I am Dhia Hannachi from Bizerte, Tunisia, studied Information Technology at ISET Jendouba and later honed my skills through commercial and freelance experience.