DEV Community 👩‍💻👨‍💻

Cover image for Speed up your local WordPress development with Docker on Windows
Mạnh Đạt
Mạnh Đạt

Posted on

Speed up your local WordPress development with Docker on Windows

If you prefer watching the experiment, here is the video:

https://www.youtube.com/watch?v=SET8P5OeBfo

Most of us when beginning developing with Docker usually mount from a local path to a path inside the containers since it's the simplest solution. However, this simplicity comes with a cost:

Speed!

Especially when you are developing on Windows.

You see, Docker on Windows, despite all the efforts cannot compare to what it's like on Linux. I have my WP sites on Linux and it loads super fast.

From what I learn, mounting the local directory to a container on Windows can make app loads very slow, not just WordPress.

So, I decided to give it a try: move codes, database to a volume.

And guess what? Speed improved immensely.

The old setup

Here is the old setup:

version: '3.8'

services:
  wp:
    image: webdevops/php-apache:7.4
    container_name: wp
    restart: always
    volumes:
      - D:\Data\dev\wordpress\main\:/app
    ports:
      - 8888:80
  db:
    image: mariadb:10.5.3
    container_name: db
    restart: always
    volumes:      
      - ./db:/var/lib/mysql
    environment:
      MYSQL_ROOT_PASSWORD: root

Enter fullscreen mode Exit fullscreen mode

You see the problem? Both db and the WordPress code are mounted from a local directory on the host machine. Thus, the site loads super slow.

The new setup

version: '3.8'

services:
  wp:
    image: webdevops/php-apache:7.4
    container_name: wp
    restart: always
    volumes:
      - wordpress:/app

    ports:
      - 8888:80
  db:
    image: mariadb:10.5.3
    container_name: db
    restart: always
    volumes:
      - db:/var/lib/mysql

    environment:
      MYSQL_ROOT_PASSWORD: root

volumes:
  db:
  wordpress:
Enter fullscreen mode Exit fullscreen mode

Now, I created two volumes, one for db and one for the WordPress code. Guess what? The site isn't slow anymore.

Give it a try

Top comments (3)

Collapse
 
mlopezcoria profile image
Mauricio López Coria

Sorry but I don't get the difference.

Collapse
 
mathieu_clment_cbe37fb0e profile image
Mathieu Clément

Old version uses local directories on the host file system, new version uses Docker volumes.

Collapse
 
lukasz_l profile image
lukaszlatacz

thx its work :)

🌚 Life is too short to browse without dark mode