Why is my php docker container so slow on Windows 11?

Update:
Ran through some tests and found out that the mount I am currently using seems to be the issue.

Current php container settings:

  php:
    build:
      context: ./
      target: dev
    container_name: ${PROJECT_NAME}_php
    volumes:
      - /mnt/c/Projects/sulu/docker/services/php/php.ini:/usr/local/etc/php/php.ini
      - /mnt/c/Projects/sulu/:/var/www/html
      - ~/.composer:/home/netbela/.composer
    environment:
      - PHP_IDE_CONFIG=serverName=${PROJECT_NAME}
    networks:
      - app-network
    env_file:
      - .env
    ports:
      - 9000:9000

Timed the execution of a composer create-project:

/var/www/html $ time composer create-project sulu/skeleton testproject -n
real    7m 40.33s
user    2m 13.54s
sys     4m 41.40s

Decided to create another docker instance without the local directories but with a docker volume and timed the exact same command.

  php2:
    build:
      context: ./
      target: dev
    container_name: ${PROJECT_NAME}_php2
    volumes:
      - php2-data:/var/www/html
    environment:
      - PHP_IDE_CONFIG=serverName=${PROJECT_NAME}
    networks:
      - app-network
    env_file:
      - .env
    ports:
      - 9001:9001

volumes:
  php2-data:
    name: php2-data

Test output:

real    0m 12.83s
user    0m 10.71s
sys     0m 2.81s

Conclusion; It has something to do with the local directories being mounted. Now to figure out how to solve this issue so that I can still work with GIT and edit my code from the Windows desktop whilst using a docker volume.

1 Like