Let’s set up a WordPress development environment with Docker on Windows

Background

WordPress is the most important and used content management system. So I still love it no matter what they say :)

  • 35% of the Internet is Powered by WordPress
  • etc etc
  • PHP module
  • A MySQL Database (Mysql or MariaDB)

Dockerize

In this article, I will try to explain how to set up my development environment.

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: {}
version: '3.3'services:
db:
image: mysql:5.7
container_name: mysql-db
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
container_name: my-lovely-wordpress
depends_on:
- db
volumes:
- C:/dev/wp/wp-content:/var/www/html/wp-content

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: {}
Docker Dashboard on Windows
Lovely logs on cmd
docker-compose.yml or docker-compose.yaml
  • run command for composer
docker-compose up -d
(heart smile) emoji
http://localhost:8000
C:\dev\wp\wp-content
Yeah, “Docker Test” theme is here!

Stop the containers

If you want to stop these containers, you can use kill command or use below:

docker-compose down
docker-compose down -v --rmi all

A Passionate Computer Engineer From İzmir

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store