3

I have created a laravel project and put it in a docker container and it all seems to load fine, however at some point I get an error message saying:

There is no existing directory at "/Users/john/Documents/work/dashboard/src/storage/logs" and its not buildable: Permission denied

It is strange that Laravel is trying to write into a file or directory that is part of my local environment, instead of the docker container environment which I would expect to be something like:

/var/www/storage/logs

This is my docker-compose.yml:

version: '2'
  services:

  # The Web Server
  web:
    build:
      context: ./
      dockerfile: web.signup.dockerfile
    working_dir: /var/www
    volumes:
      - ./src:/var/www
      - /var/www/storage
    env_file: 'src/.env'
    ports:
      - 80:80

volumes:
  dbdata:

And this is my Dockerfile

FROM centos:latest

RUN set -ex \
    && yum install -y epel-release \
    && yum update -y mysql-client libmagickwand-dev \
    && yum install -y libmcrypt-devel \
    && yum install -y python-pip \
    && pip install --upgrade pip \
    && yum install -y zip unzip  \
    && yum install -y java-1.8.0-openjdk \
    && yum clean all

RUN pip install --upgrade --ignore-installed six awscli
RUN yum install -y supervisor
RUN yum install -y php-pear php-devel 
RUN pecl install imagick 

# Add the Ngix
ADD nginx.repo /etc/yum.repos.d/nginx.repo

# Add the Centos PHP dependent repository
RUN rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

RUN yum update -y

# Installing Nginx 
RUN yum -y install nginx

# Installing PHP
RUN yum -y --enablerepo=remi,remi-php72 install php-fpm php-common php-mcrypt php-mbstring

WORKDIR /var/www

ADD vhost.prod.conf /etc/nginx/conf.d/default.conf

COPY src/. /var/www

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
    && php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" \
    && php composer-setup.php \
    && php -r "unlink('composer-setup.php');" \
    && php composer.phar install --no-dev --no-scripts \
    && rm composer.phar

RUN chown -R apache:apache \
    /var/www/storage \
    /var/www/bootstrap/cache

EXPOSE 80
EXPOSE 9000

RUN mkdir -p /run/php-fpm

COPY supervisord.conf /supervisord.conf

CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"]

Any ideas at all?

3 Answers 3

3

From my end, results are when no matter what folder permission we changed in the physical folder.

Delete everything in bootstrap/cache/* solved the issue.

Sign up to request clarification or add additional context in comments.

Comments

1

Works as designed,

you are mounting "src" from your current directory into the container.

 volumes:
  - ./src:/var/www

If you want to access your code inside the container you could add the files while building.

To fix your "bug",

chmod -R 777 /Users/john/Documents/work/dashboard/src/storage/logs

Would be ok a for local development environment

3 Comments

That doesn't do anything, it still shows the same error after doing chmod, rebuilding and running the container. The container is trying to access that folder, however it doesn't exist because the path shown in the error message actually belongs to my local environment rather than to the container filesystem.
in your docker-compose.yml file you are mounting: volumes: - ./src:/var/www - /var/www/storage And because you're mounting (nothing) to /var/www/storage/ this is happening. So if you want your logs locally, do as ^^^ says. Otherwise, just don't mount that directory.
chmod -R 777 is never a fix!
1

In my case, I got this error when I ran out of HDD space and I cleared it Only this helped:

rm bootstrap/cache/config.php

php artisan cache:clear

composer dump-autoload

Comments

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.