Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Lumethys's avatar

Some questions about sail and docker

So we are trying to move away from the LAMP stack and embrace Docker for local development. Of which Laravel had Sail as an answer

But upon investigating the docs, it seems to me that Sail works by having the source code installed in the Wsl2 itself (most of us use windows)

Is this mandatory? Do everyone on the teams must clone the repo directly on wsl2? Can I just put it in Windows and mount the folder in the container? (Most of our company computers is set up to have a folders to manage source code of all projects)

Or is it just better to just do it manually? If so, do you prefer using Docker for outside services (db, redis,...) and running the actual codebase on host machine, or do you prefer it to be all serve through a container?

0 likes
10 replies
LaryAI's avatar
Level 58

Sail does not require the source code to be installed in WSL2. It is possible to mount the source code folder from the host machine into the container. This can be done by specifying the path to the source code folder in the docker-compose.yml file. Here is an example:

version: '3'
services:
  laravel.test:
    build:
      context: .
      dockerfile: Dockerfile
    image: sail-7.4/app
    container_name: laravel.test
    volumes:
      - './:/var/www/html'

In this example, the volumes section specifies that the current directory (./) on the host machine should be mounted to the /var/www/html directory in the container.

As for whether to run the codebase in a container or on the host machine, it depends on the specific requirements of the project. Running everything in a container can make it easier to manage dependencies and ensure consistency across different environments. However, running the codebase on the host machine can provide better performance. It is recommended to experiment with both approaches and see which one works best for your project.

1 like
Lumethys's avatar

@frankielee i do know that there is performance drawbacks, but we had a dozen apps on our dozens computer all sorted on the window filesystem. I dont want to introduce more complexity in the codebase management by "some of the projects in windows, some in the wsl2".

Also, exactly how big the impact is?

frankielee's avatar

@Lumethys

exactly how big the impact is

last time with X_DEBUG was enabled, a simple http request took more than 3 seconds to fetch the response.

And sail is single thread, so the total time taken for page to render might equal to number of requests * 3 seconds

frankielee's avatar

@lumethys

last time with X_DEBUG was enabled, a simple http request took more than 3 seconds to fetch the response.

Maybe its due to my PC hardware limit, but its did reduce the time taken to milliseconds after moving to wsl2 directory

Lumethys's avatar

@frankielee that seem like a pretty big performance hit. One more question though, what is your workflow? do your team just clone the repo straight into wsl2 and work in there exclusively?

frankielee's avatar

@Lumethys

do your team just clone the repo straight into wsl2 and work in there exclusively?

Yes, however, we are not using sail unless the projects are in different php version or hard to configure.

Lets say the project are using the default enabled php-modules, we will use valet-linux instead

veinhugain's avatar

As someone with 2 many older systems lying around. You want 16GB mem min on any system you do attempt it with for sanity. Once up it is very nice to work with and you can tweak the env for different versions of this that and the other with with quick docker down & docker build & docker up. be it php version or db mysql vs mariadb redis versions. very flexible.

1 like
Lumethys's avatar

@veinhugain how are you and your team set up Sail? do everyone just clone the repo straight into wsl2 and work in there exclusively, or do you mount to docker from windows filesystem?

cwhite's avatar

@Lumethys

I use a System76 laptop now, but back when I was forced to use the Windoze virus I cloned the repo inside WSL and worked exclusively in WSL.

1 like

Please or to participate in this conversation.