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
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:
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 (5)
if this is my directory and inside the wordpress folder is the wordpress files
and my composer yml is :
How i can apply your idea? I am stuck with it.
Thanks in advance.
thx its work :)
Sorry but I don't get the difference.
Old version uses local directories on the host file system, new version uses Docker volumes.
nice, is it possible to "inspect/change/alter" the contents of that docker volume too?