sail: Sail is not working when using docker-desktop for Linux

  • Sail Version: 1.20.1
  • Laravel Version: 9.51.0
  • PHP Version: Using sail with 8.2
  • Host operating system: Linux Ubuntu 22.04.1

Description:

This bug is reproducible in Linux. Not sure what happens on MacOS or Windows.

When I run sail using the docker engine, the files in the container are assigned to sail/sail . The user/group is the expected one thus laravel.test webserver is able to serve the files with no problem.

However, when run sail using the desktop-linux context (which is the context used by docker-desktop), owner/group are not correctly set to sail/sail. Looks like volumes are handled a bit different when using docker-desktop: https://docs.docker.com/desktop/faqs/linuxfaqs/#how-do-i-enable-file-sharing

As the owner/group have changed, the webserver is not able to serve the website:

The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied

Steps To Reproduce:

  1. Install docker engine and docker-desktop in a Linux system and run both.
  2. Switch the context to use docker engine running the following command: docker context use default
  3. Run sail and check owner/group of the shared files in the container:
sail up -d
docker exec -it example-app-laravel.test-1 ls -l

You should see something like this:

drwxr-xr-x  7 sail sail   4096 Jan 31 15:05 app
-rwxr-xr-x  1 sail sail   1686 Jan 31 15:05 artisan
...
  1. Stop sail: sail down
  2. Change the context in order to use docker-desktop with docker context use desktop-linux
  3. And run the same commands
sail up -d
docker exec -it example-app-laravel.test-1 ls -l

That’s the output:

drwxr-xr-x  7 root root   4096 Jan 31 15:05 app
-rwxr-xr-x  1 root root   1686 Jan 31 15:05 artisan
...

As you can see file’s owner/group changed.

Solutions

Not sure. At the moment looks like avoid using docker desktop in Linux and use docker engine instead is a workaround.

Related: #459

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 5
  • Comments: 19 (2 by maintainers)

Most upvoted comments

PS: I dont find the comment again, but there would be a great info by docker, to comment on their installation manual for linux docker desktop, to maybe wait until this “bug” is fixed…

To all who feel a bit lost after weeks of messing around with chmod and chown, sail:sail, composer problems or whatnot: As long as docker Desktop permission issues arent fixed and work like everywhere else (docker Desktop Windows and Mac, using only docker engine (docker ce) in linux): DO NOT USE DOCKER DESKTOP FOR LINUX. IT WONT WORK OUT OF THE BOX YET. A docker devteam: Please try to fix this. After first being positively impressed by docker desktop features rich app, I had to remove it completely and work now without ANY ISSUES using docker engine and docker compose.