nteath's avatar

Laravel Sail, cannot mkdir. Permission Denied

I am using Laravel sail and when I run npm install , I get an error about permissions.

I have tried to connect to my container and attempt to make a simple directory, but it fails as well.

sail@a4b884b62480:/var/www$ ls -la
drwxr-xr-x  3 root root 4096 Jan 14 10:55 .
drwxr-xr-x  1 root root 4096 Jan 14 10:55 ..
drwxrwxr-x 12 1000 sail 4096 Jan 28 11:00 html
sail@a4b884b62480:/var/www$ whoami
sail
sail@a4b884b62480:/var/www$ mkdir html/test
mkdir: cannot create directory 'html/test': Permission denied
sail@a4b884b62480:/var/www$ 

Any suggestions please?

Edit: If I give 777 permissions to the project, from the host it works, but I 'd prefer to avoid this.

Also I 'm not sure where the user '1000' is coming from. Reading the Dockerfile I see there is a user 1337 created.

0 likes
6 replies
Tray2's avatar

Try

sudo chown sail:sail html
1 like
nteath's avatar

I cannot use 'sudo', since I 'm inside the container.

Trying chown sail:sail html returns operation permitted.

limewater23's avatar

Anyone gets the solution? I got my sail up running no problem, but once I started installing livewire, I have

  - Downloading livewire/livewire (v2.10.6)
  - Installing livewire/livewire (v2.10.6): Extracting archive
    Failed to extract livewire/livewire: (1) '/usr/bin/unzip' -qq '/var/www/html/vendor/composer/tmp-671a150cd357ce6200f26d46bd4843c5' -d '/var/www/html/vendor/composer/409acba3'

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/409acba3/livewire-livewire-020ad09/.all-contributorsrc
          Operation not permitted
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/409acba3/livewire-livewire-020ad09/.github/FUNDING.yml
          Operation not permitted
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/409acba3/livewire-livewire-020ad09/.github/ISSUE_TEMPLATE/bug_report.md
          Operation not permitted
fchmod (file attributes) error: Operation not permitted
warning:  cannot set modif./access times for /var/www/html/vendor/composer/409acba3/livewire-livewire-020ad09/.github/ISSUE_TEMPLATE/config.yml

jarribi's avatar

For me these commands worked:

sail root-shell

cd ..

chown -R sail:sail html

8 likes
longestdrive's avatar

I may be way off here but I had permission issues with my docker container and the local files. I needed to ensure the users for the container were set correctly to match the host systems user. Here's the post I made at the time and the AI answer which helped to resolve: https://laracasts.com/discuss/channels/servers/laravel-vite-on-docker-permissions-and-connection-refusedreset

can you share your docker-compose file?

User 1000 for my machine is the current user on the host machine - creating that user in the docker file I believe stops the permissions issue (or at least reduces it as mine hasn't gone away 100% of the time and needs a docker restart every now and again

Please or to participate in this conversation.