1

i'm trying to set up a laravel project with mysql, phpmyadmin on docker. All the configurations seem to be good since docker-compse up starts all. But when i try to acces to the default page i go that error on the log :

webserver     | 2020/02/03 09:02:36 [crit] 6#6: *4 stat() "/var/www/public/" failed (13: Permission denied), client: 172.18.0.1, server: , request: "GET / HTTP/1.1", host: "localhost"
webserver     | 2020/02/03 09:02:36 [crit] 6#6: *4 stat() "/var/www/public/" failed (13: Permission denied), client: 172.18.0.1, server: , request: "GET / HTTP/1.1", host: "localhost"
webserver     | 2020/02/03 09:02:36 [crit] 6#6: *4 stat() "/var/www/public/index.php" failed (13: Permission denied), client: 172.18.0.1, server: , request: "GET / HTTP/1.1", host: "localhost"

My dockerfile contains that:

# Add user for laravel application
RUN groupadd -g 1000 www
RUN useradd -u 1000 -ms /bin/bash -g www www
# Copy existing application directory contents
COPY . /var/www
# Copy existing application directory permissions
COPY --chown=www:www . /var/www
# Change current user to www
USER www

and ls -la in the containers returns:

drwx------  2 www  www    4096 Oct 18 20:10 config
drwx------  5 www  www    4096 Oct 18 20:10 database
-rw-rw-r--  1 www  www    1358 Feb  3 08:48 docker-compose.yml
drwx------  2 www  www    4096 Oct 18 20:10 mysql
drwx------  3 www  www    4096 Oct 18 20:10 nginx
-rw-rw-r--  1 www  www    1125 Oct 18 20:10 package.json
drwx------  2 www  www    4096 Oct 18 20:10 php
-rw-rw-r--  1 www  www    1156 Oct 18 20:10 phpunit.xml
drwxrwxrwx  4 www  www    4096 Oct 18 20:10 public
drwx------  6 www  www    4096 Oct 18 20:10 resources
drwx------  2 www  www    4096 Oct 18 20:10 routes
-rw-rw-r--  1 www  www     563 Oct 18 20:10 server.php

I don't know what's wrong. i found this Permission Denied Error using Laravel & Docker but i doesn't works.

9
  • Is the nginx user www? Commented Feb 3, 2020 at 9:19
  • Yes you can see in the docker file that i create the user www Commented Feb 3, 2020 at 9:20
  • Yes, but is the nginx configured to run as www user? Commented Feb 3, 2020 at 9:21
  • I don't realy understand what you mean Commented Feb 3, 2020 at 9:23
  • 1
    Try setting chmod +X /var/www (capital X) - will add search permission to directories for all users. Commented Feb 3, 2020 at 9:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.