A Symfony or PHP app in Docker Desktop for Mac takes seconds per request
Your error
Symfony pages take several seconds in Docker Desktop on a Mac but respond quickly on a Linux server1 more line it can showFix it fast
Most common cause, 1 of 3vendor/ and var/ sit on the bind mount
Lay named volumes over vendor and var so those paths stay inside the VM, then fill vendor once from inside the container.
services:
php:
volumes:
- ./:/var/www/app
- vendor:/var/www/app/vendor
- var:/var/www/app/var
volumes:
vendor:
var:
docker compose up -d
docker compose exec php composer installShort answer
Docker Desktop on macOS runs containers in a Linux VM, so each file a request reads from a bind mount crosses a host-to-VM share. Symfony reads thousands of files from vendor/ and keeps cache and logs in var/. Put vendor/ and var/ in named volumes, use VirtioFS for file sharing, and try synchronized file shares for very large projects.
Which cause do you have?
Time one console command inside the container, then list what compose.yaml bind-mounts from the Mac. A project mount with no volume over vendor or var points to the first cause.
time docker compose exec php php bin/console cache:clear
docker compose config | grep -n -B1 -A4 "type: bind"Then find the line you see in this list and open its fix:
- 1vendor/ and var/ sit on the bind mount
compose.yaml mounts the whole project, for example ./:/var/www/app, and no named volume covers vendor or var - 2File sharing still runs on gRPC FUSE
Settings > General in Docker Desktop shows gRPC FUSE as the file sharing implementation - 3The project is too big for a virtual file share
VirtioFS is on and vendor lives in a volume, yet file-heavy commands stay slow in a repository with a very large file count
What does the error look like?
Symfony pages take several seconds in Docker Desktop on a Mac but respond quickly on a Linux servercomposer install and bin/console cache:clear are much slower inside the container than on the host
Cause 1 of 3
vendor/ and var/ sit on the bind mount
You seecompose.yaml mounts the whole project, for example ./:/var/www/app, and no named volume covers vendor or var
Check
Docker's settings guide for Mac says file sharing adds overhead because host changes must be reported to the Linux VM, and that cache directories or databases perform much better when kept inside the VM. A Symfony project mounted whole breaks that advice: Composer's vendor tree and the var/cache and var/log folders all travel through the share.
docker compose config | grep -n -A3 'target: /var/www/app'Fix
Lay named volumes over vendor and var so those paths stay inside the VM, then fill vendor once from inside the container. The host copy of vendor then stops changing, so run composer install on the Mac as well if your IDE needs it.
services:
php:
volumes:
- ./:/var/www/app
- vendor:/var/www/app/vendor
- var:/var/www/app/var
volumes:
vendor:
var:
docker compose up -d
docker compose exec php composer installVerify
The same timed command finishes far sooner than before.
time docker compose exec php php bin/console cache:clearConfirmed by docs.docker.com
Cause 2 of 3
File sharing still runs on gRPC FUSE
You seeSettings > General in Docker Desktop shows gRPC FUSE as the file sharing implementation
Check
Docker Desktop for Mac can share host files through VirtioFS or gRPC FUSE. VirtioFS is the default and the one Docker recommends for speedy file sharing, so a setting switched during earlier troubleshooting leaves every bind mount on the slower path.
# Docker Desktop > Settings > General > Choose file sharing implementationFix
Select VirtioFS, apply, and let Docker Desktop restart the VM; containers come back with the new file share.
# Docker Desktop > Settings > General
# file sharing implementation: VirtioFS
# Apply & restart
docker compose up -dVerify
The setting shows VirtioFS after the restart, and the timed command improves.
time docker compose exec php php bin/console aboutConfirmed by docs.docker.com
Cause 3 of 3
The project is too big for a virtual file share
You seeVirtioFS is on and vendor lives in a volume, yet file-heavy commands stay slow in a repository with a very large file count
Check
Docker aims synchronized file shares at codebases of 100,000 files or more, where VirtioFS and gRPC FUSE no longer scale. Docker Desktop then keeps a synchronized copy of the host folder in the VM, and bind mounts of that folder read from the copy.
find . -type f | wc -lFix
The feature needs you signed in to Docker Desktop. Under Settings > Resources > File sharing, choose Create share in the Synchronized file shares block and pick the project folder. Each share holds about 2 million files at most, so split larger trees into several shares.
# Docker Desktop > Settings > Resources > File sharing
# Synchronized file shares > Create share > select the project folder
# wait for: Watching for filesystem changesVerify
The share's status reads Watching for filesystem changes, and the timed command speeds up without any change to compose.yaml.
time docker compose exec php php bin/console cache:clearConfirmed by docs.docker.com
How do I stop it coming back?
- Start every PHP compose.yaml with named volumes for vendor, var, node_modules and database data, and bind-mount only the source code.
- Keep Settings > Resources > File sharing limited to the folders your containers need, as Docker's guide recommends.
- Run composer install inside the container after each change to composer.lock, because the volume copy of vendor does not follow the host folder.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine on the same stack: TaxiDex, Dispatch Pro, Spotless Laundry.