Devlibox (Docker) extremly slow on Mac
OK, I tried docker-sync and I did not realize any speed up. I decided to install Valet plus as I need to have multiple PHP version (easily switchable), MailHog, Xdebug, SSL on local domains, DnsMasq etc. All of this comes out of the box in Valet plus. I thought it would be much better to develop in Docker but Symfony uses really a lot of cached files on disk so this was really unusable (as page load was between 30 to 60 seconds).
Running Docker containers slows down new Macbook Pro to a crawl
Managed to somewhat fix the issue by adding :cached
to the PHP volume in my docker-compose.yml
file;
php:
build: php-fpm
volumes:
- ../:/app:cached
working_dir: /app
Page load times can still get to 3/5 seconds, but at least my Mac doesn't slow down anymore and it's still a massive improvement over the 10s/1m+ loadtimes I was seeing earlier.
Docker running really slow on mac after PHP 7.4 8 update
Found it eventually, posting an answer in case it helps anyone else.
Adding the following variables to docker-compose.yml
resolved the issue.
services:
laravel.test:
environment:
XDEBUG_MODE: '${SAIL_XDEBUG_MODE:-off}'
XDEBUG_CONFIG: '${SAIL_XDEBUG_CONFIG:-client_host=host.docker.internal}'
Laravel Docker For Mac Very Slowly
Docker on OS X is just slow. Newer Docker versions have improved this.
Are you actually deploying this Dockerized? If not, consider just using artisan serve
.
Docker Wordpress super slow
TL;DR
Mount to temporary folder on container, sync that folder with Bindfs to public server folder.
Serving WP site with direct mount is slow because container has to access Host files one by one, which is a heavy process. Serving from public folder while files being part directly of container is much faster.
I've encountered exactly the same problem with local WordPress on Docker Compose development. It doesn't matter how fast your computer might be, it'll still be slow when mounting the folders in the containers.
I also tried solutions like NFS and other recommendations like properly excluding the project in the antivirus, adding .dockerignore, etc. which at best improve just slightly the performance.
While browsing for a similar speed improvement I came across this Dockerfile at the WordPress Starter repository https://github.com/visiblevc/wordpress-starter/blob/master/Dockerfile.
If you look at this file you'll see that the way they intialize and mount the project in the container is by mounting it not to, let's say, /var/www/html/ directly, but a temporary folder instead. Then they sync this temporary folder to /var/www/html/ through bindfs. This way every time you load a WordPress page in the browser it'll be lightning fast because it won't have to access and read the Host files on every request. The WordPress files are part of the Linux container. When you make changes to your code those changes will reflect on the container temporary folder and bindfs will instantly sync those changes over to the public container folder, and same the other way around. All changes made on the public folder will be synced over to the temp folder, and from there to your Host project files.
Docker slow on OS X Symfony
Problem solved. More info about performance on MAC OS here https://docs.docker.com/docker-for-mac/osxfs-caching/
So I mounted my volumes using delegated like this:
apache:
build: .docker/apache
container_name: sf4_apache
ports:
- 80:80
volumes:
- .docker/config/vhosts:/etc/apache2/sites-enabled:delegated
- .:/home/wwwroot/sf4:delegated
depends_on:
- php
Default skeleton Symfony 4 project now loads in less than 1 second. It is still kinda slow, but it's ten times faster than before. :)
Related Topics
Codeigniter: Passing Data from Controller to View
What Are the Differences Between Composer Update and Composer Install
Post a File String Using Curl in PHP
Fatal Error: Call to Undefined Function Mb_Detect_Encoding()
Verify Receipt For in App Purchase
PHP Post_Max_Size Overrides Upload_Max_Filesize
Byethost Server Passing HTML Values "Checking Your Browser" With Json String
Set Pdo to Throw Exceptions by Default
How to Check If a Word Is Contained in Another String Using PHP
What Exactly Is Path_Info in PHP
Simplexml and Print_R() - Why Is This Empty
Show a Pdf Files in Users Browser Via PHP/Perl
Using MySQLi Bind_Param With Date and Time Columns