Closed cyrrill closed 3 years ago
I have my Dockerfile add the sail user to a sail group, copy the source code into the image, and change the group ownership of the project to sail. Group owner permissions are sufficient enough for sail to access the file system. If I change the ownership to sail it overwrites and persists my desktops personal folder since I overwrite the copied project with my modified changes by mounting a volume to the same directory. That caused me to have to change them back to my user as root.
This is the worst bug I've ever encountered in my life, I've been completely stuck on it for the past 6 days. I've tried Linux, Windows, and Mac, I've reinstalled the OSs at least 3 times each, I've tried over 50 different proposed solutions. This crap simply doesn't work. Please fix this, I beg you.
@iamcarlos94 I had this issue but for me it was having docker installed twice. I installed docker desktop on top of docker engine for Linux which messed up my permission (i think). I never install the desktop version in Linux anymore and use Portainer if I need to see what is going on.
There was also a part I missed which checks UID where is was 1000 but I cannot seem to find that part. It was hidden away in a paragraph link, but there was this post install link I just found regarding groups etc https://docs.docker.com/engine/install/linux-postinstall/ It also says you should log out and log in to get permissions reevaluated. Not login out and in may have caused me a lot of issues too? I was stuck on this for days. It almost blew my head up! I wish I could be more specific about a fix as after you've been repeatedly trying to install over several days you tend you rush over stuff and can miss things.
@warmwhisky I have tried both with and without Docker Desktop and both with root and non-root installation. I feel like I've tried everything at this point. This is supposed to be an easy and simple method of properly running Laravel but it's actually anything but. It's very upsetting seeing so many people having the exact same problem yet this issue is closed.
@iamcarlos94 Try stopping in docker desktop if it is running, the via command line in the Ubuntu (or your Linux environment) terminal run the following command while in the root directory of your laravel application:
sail up -d
Please report back if this resolved your issue.
On Thu, Dec 22, 2022, 10:04 AM iamcarlos94 @.***> wrote:
@warmwhisky https://github.com/warmwhisky I have tried both with and without Docker Desktop and both with root and non-root installation. I feel like I've tried everything at this point. This is supposed to be an easy and simple method of properly running Laravel but it's actually anything but. It's very upsetting seeing so many people having the exact same problem yet this issue is closed.
— Reply to this email directly, view it on GitHub https://github.com/laravel/sail/issues/81#issuecomment-1362945502, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFTAHIPFCW5XHSH2Q7FZVZTWORUXHANCNFSM4ZYXY44Q . You are receiving this because you commented.Message ID: @.***>
@iamcarlos94 Absolutely, it's nuts isn't it. I've ditched docker now, and reverted back to using Laragon. It's just frustrating because all the new documentaiotn and how to videos going about at the moment, suggest just creating docker instances, and doing all that process, but it's always being shown on macs, which really isn't that helpful for us windows users.
@legendarylion I have tried that too as I've seen a lot of people reporting issues with wrong UID when starting the containers from Docker Desktop instead of using the terminal. No luck.
@iamcarlos94 I added the group and user to my env to get this to work I think. Any good to you?
WWWGROUP=1000
WWWUSER=1000
@MeepMeeps I tried that too, it was the first thing I tried actually.
I've decided to give up and go back to Windows + Laragon, far too much time wasted already.
If you are using Sail (Docker) then try this command
sail artisan storage:link
It's Solve my storage folder access issue, I am using Laravel 9.
This give me: symlink(): Permission denied error
- login to sail as root
sail root-shell
- give permission to user sail as
chown sail -R storage/
This pretty much solved mostly everything, after doing this: 'chown sail -R ./' it solved everything
I had also a painful road to figure out how to solve a similar error message.
Error (shown via browser or sail php artisan storage:link
)
The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened in append mode: Failed to open stream: Permission denied
Requirements
docker
and python3-docker-compose
via zypper as described in this tutorialSolution steps:
groupadd www-data
WWWGROUP=1000
and WWWUSER=1000
to the .env
from the project-folder (here: ~/chirper)sail down
sail up
Now the error-message is gone.
Not sure if this is related, but I got some issues myself when using docker desktop on ubuntu 22.04. I found this issue on docker desktop for linux: https://github.com/docker/desktop-linux/issues/31
Which in short tells us that they mount root to the current user, and other users inside the container gets a user and group id based on some range. So even if the sail user has id 1000, and the host machine user has id 1000, it will not be the same id when mounted via docker desktop. In my case i got 100999 as the user id
My workaround (from the tips in the issue) was to create a group with the actual id (100999 in my case) and give that group to my account as well.
To get it fully working with sail, i then changed the user and group to id 100999
on all the files, as well as giving group write access.
Not sure if this is related, but I got some issues myself when using docker desktop on ubuntu 22.04. I found this issue on docker desktop for linux: docker/desktop-linux#31
Which in short tells us that they mount root to the current user, and other users inside the container gets a user and group id based on some range. So even if the sail user has id 1000, and the host machine user has id 1000, it will not be the same id when mounted via docker desktop. In my case i got 100999 as the user id
My workaround (from the tips in the issue) was to create a group with the actual id (100999 in my case) and give that group to my account as well. To get it fully working with sail, i then changed the user and group to id
100999
on all the files, as well as giving group write access.
From what I've been noticing from my own issue on this today, it's specifically if you run docker rootless on linux (or at least that sounds like the more common case?).
I tried chown -R sail:sail ./
in a container root shell, which ended up flipping the host ownership to root and container ownership to sail. When I did the reverse from the host, I got the 100999
you mentioned.
For now, I've just gone back to root docker. Rootless generally doesn't seem to be well supported.
i like how this issue is "closed" yet still very active. classic laravel community.
Also experiencing this problem, Docker Desktop on Ubuntu 22. Don't tell me not to use docker desktop, that's not a solution. Write documentation that will allow your app/package to work where it is supposed to work: in docker. Docker desktop is an extremely common installation these days especially with it's recent debut in Linux.
Do better.
For anyone facing this issue with the owner being
1000:sail
instead ofsail:sail
, you have probably started the container using Docker (Desktop) instead of usingsail up
.Use
sail up
and the owner will be set correctly - no need to manually set owners or change the WWWUSER.
This was the solution for me. First time everything was working, as I ran sail up
, but the second time I started the container trough Docker Desktop, and got the permissions error when doing composer update
. Running the container through sail up
fixed the problem.
First, just try composer install
A lot of people are saying to start sail from the command line to fix it. For me, I had to remove the image first, since I had already started the container with docker desktop once. For me, these steps did the trick:
docker container prune
docker rmi sail-8.2/app
(change php version to your own)./vendor/bin/sail up
or sail up
Using docker desktop to enter the container terminal seems to not cause any issues.
For anyone facing the same issue as the one described in the original posting, have a look at Docker contexts. Like images, containers, volumes, and networks, contexts constitute a fundamental entity in the Docker ecosystem.
Without delving too deeply into the details, I found out that the currently selected context affects the behaviour of Docker in many ways, especially in the way that it handles volumes.
Here's my fix: set Docker's context to "default", as opposed to "desktop-linux", through this command in your terminal...
docker context use default
Sail things up again, and everything should be working just fine.
Hence, the bash script that we curl to get a Sail-ready Laravel installation on a development host is designed to be used under the "default" context, as opposed to the "desktop-linux" context. I don't know if that should be interpeted as a bug, but I wonder what is the logic behind having a "desktop-linux" context that is not working on a Linux desktop!!! Damn!
Hi everyone, here is my humble opinion (excuse my English).
I'm experiencing this same issue today, Ubuntu 22.04, Docker Desktop 4.17, Laravel 10.6, Sail 1.21, fresh installation of everything, following instructions from official web (curl + sail up from terminal), so I think this is an issue that should be taken care of. It's not only related to storage folder, also to artisan make commands and then editing from host.
I'm building a small tutorial for my students (absolut beginners :zap:) and it is weird to say in it "if it doesn't work change to 777" or "do not use Docker Desktop" (when that is exactly what Docker is recommending) or "create a new group, modify permissions, etc"...
I've got it working with @molteber 's suggestion, but it involves changing things in the system and..... I'd rather not do that. @erictourigny23 I couldn't change context cause when I do that I receive a "Docker is not running" message on "sail up". As @iamcarlos94 said, I've tried almost everything in the thread.... Very frustrating.... It should be working without changing anything :sweat_smile:
I'd like to help here, but my knowledge on the issue is too shallow now. I'll keep getting back here and meanwhile learning about how Docker really works :smiley:
@pista7 Try this...
1) Launch Docker Desktop (make sure it is running on your machine).
2) Open a terminal, and type...
docker context use default
3) Get into your application's root directory and type...
docker ./vendor/bin/sail up
Let me know if that works. Oh, and send me a screenshot of the output of the following command...
docker context ls
@erictourigny23 Thanks for the reply!
After point 2. I get a message docker: './vendor/bin/sail' is not a docker command.
.
This is the output of docker context ls
:
If I type sail up
I get the old Docker is not running
. Earlier this morning, when I first tried, I was restarting Docker Desktop after changing context, to avoid the Docker is not running, but context was back to desktop-linux after restart. So I tried adding a linux env var (DOCKER_CONTEXT) with the same 'not running' result. :shrug:
@pista7 Sorry to hear this, I know how these things can get so frustrating. Can you send me a screenshot of systemctl --type=service --state=running
?
Hi @erictourigny23! Thanks again for your attention!
I wouldn't like to focus the discussion on my problem. I really appreciate your help, but I believe this needs a general solution for everyone. Something that works right away, as it says in the Laravel docs. Maybe in support forums we could follow your suggestion and find out what is happening.
Maybe the issue could be reopened? Obviously it is not fixed.
This issue should be reopened. I've had to leave Ubuntu and develop on Windows to get this to work as it should.
Hello @erictourigny23! I can't thank you enough for commenting on the solution to my problem. I installed ubuntu 22.04, laravel sail and tried to create something using sail artisan make: but encountered the Permission denied error. Your comment saying to change the docker context from desktop-linux to default solved my problem. Thank you very much again!
Very disappointed tried everything no results. I will have to remove sail chmod (directory attributes) error: Operation not permitted fchmod (file attributes) error: Operation not permitted warning: cannot set modif./access times for /var/www/html/vendor/composer/a89fac22/php-fig-cache-aa5030c/CHANGELOG.md Operation not permitted
@cyrrill I can write to the storage folder just fine and this is the first report we've gotten on it. Please try a support channel.
this is concerning. does this mean when the issue is indeed a bug by your standards, it means it didn't even work on the dev's machine but you published it anyway?
@pista7 @erictourigny23 Following your descriptions of the problem I was able to solve it here on Linux Pop OS. Thanks!
I figured out that installing Docker Desktop adds the context desktop-linux
. And as @erictourigny23 already pointed out, the permission error occurs when you run docker with sail inside that context.
The reason for me why Docker is not running
appeared was, that Docker Desktop is automatically changing the context to desktop-linux
as soon as you start it (see https://docs.docker.com/desktop/faqs/linuxfaqs/#context).
I did not find the time to dig deeper why the desktop-linux
context is not working with sail though but probably the context is messing with the user.
Thanks a lot @erictourigny23, changing the docker context also solved the issue for me:
docker context use default
@matthiascw Same here: I did not find the time—nor the motivation—to delve into the reason(s) why that so-called « desktop-linux context » is not working with Sail. Honestly, I'm so busy at work, I can't really get any further than this on that specific topic. But I'm still wondering why @cyrrill, the original author of this thread, has once considered that this issue was closed; I mean, even with my fix, this thread should remain open.
@basvdhoeven Glad to hear this!
@matthiascw Same here: I did not find the time—nor the motivation—to delve into the reason(s) why that so-called « desktop-linux context » is not working with Sail. Honestly, I'm so busy at work, I can't really get any further than this on that specific topic. But I'm still wondering why @cyrrill, the original author of this thread, has once considered that this issue was closed; I mean, even with my fix, this thread should remain open.
On the contrary, 2 years and 80+ comments later, I'm still following this thread hoping it actually gets fixed :)
@cyrrill Oh! Sorry for my wrong assumption, my bad. Have you tried to escalate this issue elsewhere?
@erictourigny23 not really, as this is the place where these bugs ought to get reported and the maintainer decided to close it. If you have luck elsewhere, please let us know. 👍
Can't believe this is still happening with a completely fresh and stock install of Linux and Docker.
@driesvints Could there at least be some documentation added on this problem? Since it seems rootless or Desktop Docker seem to be the main culprits here and they aren't uncommon setups.
Hi all. I'm sorry, I unsubscribed after my original comment and didn't see all the replies here. We'd be more than happy to accept a PR to the docs about some notes around this if anyone is willing to send one in. Sorry I didn't give this ticket the attention it deserved.
@driesvints would it be possible to change the status of this issue back to open then?
@driesvints I've made a PR which adds a warning about this issue to the docs (https://github.com/laravel/docs/pull/8898).
The docs have been updated: https://github.com/laravel/docs/pull/8901.
I was able to solve this by adding to docker-compose, in laravel.test
services
environment:
WWWUSER: '${WWWUSER:-1000}'
WWWGROUP: '${WWWGROUP:-$(id -g)}'
Before adding this, sail artisan storage:link
did not work, after adding it, dowing and upping sail sail artisan storage:link
did work.
for me the problem is because i'm using docker desktop. it cause the owner of container directory became root, but my user is sail. when i change the owner from root to sail my host also change into 100999:100999. now i can generate file using artisan make, but i can edit the file because of the ownership became 100999:100999. then i try to change my context to desktop default, but i get error message docker is not running. then i see the error message on service bar (php storm) it says that permission denied. then i try to change ownership on docker socket to my user and everything works fine
Yesterday I finally got the time to try out sail. Everything worked great up until this strange issue, and since my application handles a lot of files on disk I'm completely shut down. Switching docker context does not work since then Docker wont be running, as some one else has written in a previous comment. Tried with:
environment:
WWWUSER: '${WWWUSER:-1000}'
WWWGROUP: '${WWWGROUP:-$(id -g)}'
Does not work either.
This should be a pretty big show stopper for a lot of people? Why is there no solution available?
I bumped into this as well and read this issue seeking for help. I'm running an Ubuntu 22.04, fresh install. Like most, I installed Docker through Docker desktop.
The suggestions around changing the docker context lead me to uninstall Docker Desktop and to install Docker Engine the way we used to before Docker desktop, through Docker's apt repo (https://docs.docker.com/engine/install/ubuntu/).
I also made the known configurations to be able to run Docker Engine CLI commands without sudo.
With this, the problem went away for me. I know it's not really a solution but until there is one, maybe this will help other people like me trying to learn Laravel from an Ubuntu machine.
@Dasher83 I am pretty sure this is what happened to me early this year. I was install docker on a lot of systems and early in that process I tried docker decktop for Linux and this is the only time I saw this issue. Using the Docker Engine is the way to go.
@pista7 Try this...
- Launch Docker Desktop (make sure it is running on your machine).
- Open a terminal, and type...
docker context use default
- Get into your application's root directory and type...
docker ./vendor/bin/sail up
Let me know if that works. Oh, and send me a screenshot of the output of the following command...
docker context ls
Thank you so much. Thats worked for me.
For me the solution was running:
sail artisan route:clear
sail artisan config:clear
sail artisan cache:clear
A similar error could occur if you cleaned the cache, not through the sail artisan config:clear
command, bus used php from your system php artisan config:clear
. Clear the cache using sail container.
A similar error could occur if you cleaned the cache, not through the
sail artisan config:clear
command, bus used php from your systemphp artisan config:clear
. Clear the cache using sail container.
This turned out to be the issue for me. Re-running as sail artisan config:clear
fixed it.
Description:
Unable to write to storage folder.
Steps To Reproduce:
I have installed Sail into an existing Laravel 8 application as per the installation guide. The container and associated services come up and yield no errors.
When I attempt to access the application from the browser, the exception mentioned above shows up.
Normally, all you need to do is
chmod
and/orchown
the /storage/ folder in order for Laravel to run.When I try to publish the Dockerfiles (in order to attempt to set permissions), I get this other exception: