5

I would like to use Docker for local development. When I create a container with Wordpress using Docker Compose, everything loads very quickly in the browser. It's much faster than using Local by Flywheel. The problem is that I do not have access to Wordpress files. To access these files, I added volumes to docker-compose.yml:

volumes:
  - ./wp-content:/var/www/html/wp-content

I can access the files now, but everything loads so slowly in the browser that using Docker loses its meaning. Is it possible to speed it up in any way?

Ivan
  • 51
  • 1
  • 5
  • Bind mounts (what you use) are designed to be faster than volume. It doesn't make sense. Maybe you have contention issue on that folder/volume of your host. If you are on linux, you can watch FS operations with `iotop` prog. – davidxxx Oct 24 '20 at 11:00
  • Thank you. Loading time in the browser is something around 8s. I'm using Windows 10. I still have no idea .. Now I'm trying to find out if this message is related in any way: "Docker Desktop has detected that you shared a Windows file into a WSL 2 container, which may perform poorly"... – Ivan Oct 24 '20 at 21:36
  • I wrote a docker wordpress tut yesterday which my `docker-compose.yml` config creates persistent local mapping of individual `wp-content` folders, `plugins`, `uploads`, etc. Loading the entire `wp-content` folder seems excessive. My walkthrough is based on mac, so some commands may slightly differ. See if my `docker-compose.yml` setup works for you... https://stackoverflow.com/questions/64473536/why-is-this-volume-mounted-as-read-only/64493602#64493602 – joshmoto Oct 24 '20 at 23:14

1 Answers1

1

The problem is about "consistency type" in volume. Set it up as "cached"

services:
    wordpress:

        ...

        volumes:
            - ./data:/data
            - ./scripts:/docker-entrypoint-initwp.d
            #- ./wp-content:/app/wp-content
            - type: bind
              source: ./wp-content
              target: /app/wp-content
              consistency: cached
            #- ./php-conf:/usr/local/etc/php
            - type: bind
              source: ./php-conf
              target: /usr/local/etc/php
              consistency: cached

Here for more details

molavec
  • 8,848
  • 1
  • 27
  • 22
  • Thank you for your tip! I will definitely try someday. I think I've already figured out how to make Wordpress faster. Previously, I had it installed on a Windows file system. It is much faster to have it installed on WSL. – Ivan Mar 24 '21 at 07:06