To render the main PHP request, it lasts 9500ms on Docker Mac. I’m using it for a PHP project using Symfony2 framework. Docker for mac is currently very slow when I run my environment.My local file system is setup to allow Docker to map volumes to my local machine, the folder structure looks this:My docker-compose.yml file is used to launch my Drupal 8 site with a mapped volume, specifically see the volumes section under drupal_dev. Using Docker on Windows with Hyper-V was really slow too.First of all lets setup the site and witness how slow it is. Initial Setupadding to what Mathias said: OSX Filesystem is slow as well, which really comes in play when. I am going to assume you are familiar with Docker and Docker Compose. While I am using Drupal 8 development as an example, this technique will help speed up any sites running with large volumes mapped.Note that each site you work on will need one of these docker-sync.yml files, and there are many different ways to configure seperate sites. Configure Docker SyncFirst up we will configure a docker-sync.yml file to tell Docker Sync what files to sync and how to sync them. If you do not have RubyGem installed, see this article on Installing RubyGem.Once installed, we will configure Docker Sync to sync our Drupal 8 files from our mapped volume.
Docker Extremely Slow For Mac Is CurrentlyUpdating Docker ComposeWe’ll need to modify our docker-compose.yml file to use Docker Sync. For more examples check the Docker Sync Boilerplate repository.Now that we have our Docker Sync file configured, we’ll let our containers know about Docker Sync with external volumes. (More on this later).Note: As mentioned there are many ways to configure syncing your volume data, with only a default docker-sync.yml file shown that works out of the box for OSX. Notice the comment (left in from the example) that suggests always including -sync, which will help you differenciate your containers. This is the name of our sync that we will use later. Best mac face primer for oily skinLaunch the SiteFirst, launch your containers using docker-compose exactly like you normally would: $docker-compose up -dCreating network "drupal_dev_default" with the default driverWith your containers launched, next launch the sync container: $docker-sync startOk Starting native_osx for sync drupal_dev-syncThis will kick off the sync process, you’ll notice at the end of the output. With both the Docker Sync config ready and Docker Compose up to date, we are ready to launch the site. For more information, Docker has great documenation on this subject here. Remember our naming conventioned mentioned earlier, where we add -sync to the end of our container name? This is the connection between the two.Essentially here we are telling Docker to use an external container to control how our volumes are mapped, with drupal_dev-sync doing the mapping work.Note: Mapping volumes in Docker is a full subject on its own. Here is what our new docker-compose.yml file looks like: version: '2.1'First we change the volume mapping to use drupal_dev-sync:/var/Then the new volumes options defined at the end of the file, drupal_dev-sync. With my initial setup using the Drupal 8 site was unbearable with the 20+ second load time for each page and I would have ditched mapped volumes without this solution.Next I am going to look at debugging with Visual Studio code, and explore how the debugger can connect with mapped volumes. ShortcutsDocker Sync comes with a few handy commands to speed up typing all of those commands:To launch the full stack and sync: docker-sync-stack startTo remove all containers, similar to docker-compose down: docker-sync-stack cleanHaving Docker Sync running to sync files from mapped volumes has saved the day when doing local Drupal 8 development. And again, with the -sync added to the name for clarity: $docker psNow your site should be running much quicker!Note: I know 11 seconds load time is not that fast… but way faster than 18 seconds in the first test! Your site will be much faster after install.
0 Comments
Leave a Reply. |
AuthorBen ArchivesCategories |