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

I am trying to setup a development environment on my Windows 11 (Build: 22000.376) laptop. I have initialy created the environment on a Ubuntu 20.04 workstation and it worked perfeclty.

It consists of the following containers;

  1. nginx (nginxinc/nginx-unprivileged:1.20.1-alpine)
  2. php (php:8.0.9-fpm-alpine3.14)
  3. Percona database
  4. Redis cache
  5. Adminer

All the containers reside in the same ‘app-network’, the percona and redis servers have dedicated volumes. Everything works fine but the PHP container. I tried installing Sulu CMS on it through composer and was quite slow during installation. I noticed some erros during install;

    Failed to extract doctrine/annotations: (1) '/usr/bin/unzip' -qq '/var/www/html/tomtest/vendor/composer/tmp-6c0172a63ff2b134ca6392ad7ff111d1' -d '/var/www/html/tomtest/vendor/composer/77e4d756'

unzip: short read

However the installation went through and completed succesfully. Now when I try to access the skeleton admin dashboad it takes about 20 seconds to load the login screen. It seems as if the PHP container is not running correctly on Windows 11, Has anyone had problems with this kind of setup?

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

I have created a docker volume that points to the WSL filesystem.

docker volume create --driver local -o o=bind -o type=none -o device="\\wsl$\Ubuntu-20.04\home\user\sulu" php

I then mounted this docker volume onto the container and added the external: true flag

  php:
    build:
      context: ./
      target: dev
    container_name: ${PROJECT_NAME}_php
    volumes:
      - php:/var/www/html
      - ~/.composer:/home/user/.composer
    environment:
      - PHP_IDE_CONFIG=serverName=${PROJECT_NAME}
    networks:
      - app-network
    env_file:
      - .env
    ports:
      - 9000:9000

volumes:
  php:
    name: php
    external: true

With this my issue has been resolved.

1 Like