close

[Solved] Permission Denied Error using Laravel & Docker

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Permission Denied Error using Laravel & Docker in php. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Permission Denied Error using Laravel & Docker Error Occurs?

Today I get the following error Permission Denied Error using Laravel & Docker in php.

How To Solve Permission Denied Error using Laravel & Docker Error ?

  1. How To Solve Permission Denied Error using Laravel & Docker Error ?

    To Solve Permission Denied Error using Laravel & Docker Error I found similar problem and I fixed it by
    chown -R www-data:www-data /var/www chmod -R 755 /var/www/storage

  2. Permission Denied Error using Laravel & Docker

    To Solve Permission Denied Error using Laravel & Docker Error I found similar problem and I fixed it by
    chown -R www-data:www-data /var/www chmod -R 755 /var/www/storage

Solution 1

I found similar problem and I fixed it by

chown -R www-data:www-data /var/www

chmod -R 755 /var/www/storage

Solution 2

When using bind mounts in Docker, the original permissions in the Docker host are preserved in the container. This enables us to set appropriate permissions on the Docker host, to be used inside the container.

First, you should find the uid and gid of the nginx, for example:

docker-compose exec nginx id www-data

The output of this command would be something like this:

uid=33(www-data) gid=33(www-data) groups=33(www-data)

Then, you should use these uid and gid to set permissions on Docker host, which will be used by the container too. So, run the following command on the Docker host:

sudo chown -R 33:33 site

Now everything must be working.

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also, Read

Leave a Comment