How to change permissions of a docker mounted volume on OSX to work with Nginx web server running Laravel 5.1?

I am using Docker running Laravel 5.1 to generate PDFs so my problem is the file gets generated successfully without errors and is saved to the mounted volume. The problem arises when i try to pull the file back to display it using Storage::disk('local')->get($filename); I get

ErrorException in Local.php line 187:
file_put_contents(/app/storage/app/savedfile.pdf): failed to open stream: Permission denied.

I also tried changing the permissions from inside the docker container, and also manually on the mounted volume, it did not help.

  • eclipse che docker - can not create workspace - <no value>/lib/linux_amd64/terminal
  • Jenkinsfile docker
  • Hot swap port mappings on docker containers
  • Why is docker stats CPU Percentage greater than 100 times number of cores
  • Can I connect to remote DB server from inside docker container?
  • Docker build “Could not resolve ''” apt-get fails to install anything
  • Here is the code i used to save the file

        $snappy = new Pdf('wkhtmltopdf');
        $tmpFile = storage_path().'/app/savedfile.pdf';
        $snappy->setOption('images', true);
        $snappy->setOption('footer-right', '[page] OF [topage]');
        $result = $snappy->generateFromHtml(
        Storage::disk('local')->put('report.pdf',  \File::get($tmpFile));

    Does anyone know how i can resolve this?

  • Can docker containers be run on live web servers?
  • Docker & nginx operation not permitted
  • Change “hosts” / “-h” Docker for Windows in daemon.json
  • Is it possible to start multiple docker daemons on the same machine
  • Deployment Rails app for Docker
  • Best practice: Python development environment with docker for mac
  • One Solution collect form web for “How to change permissions of a docker mounted volume on OSX to work with Nginx web server running Laravel 5.1?”

    Docker users are not the same as the host machine’s.
    You need to make sure that the host machine’s user and container’s user that access the mounted volume have both access to the volume’s files.

    You can achieve this in a couple ways, for example:

    1. Make the files world readable/writable
    2. Make sure the user ID of both host computer and container is the same
    3. Change permissions of the file after it’s written

    After you make the change you should be able to read/write the pdf files.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.