Search code examples
laraveldockerdocker-composelaradock

What is the correct way to install laravel in laradock?


I have install and setup laradock in my machine and did the following as per the documentation.

  1. sudo docker-compose up -d mysql nginx php-fpm workspace phpmyadmin
  2. sudo docker-compose exec workspace bash
  3. composer create-project laravel/laravel blog

with the above commands the laravel is installed successfully but I get the following error:

The stream or file "/var/www/blog/storage/logs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

And found out in doc that I need to pass user to bash to avoid this error. So I did:

  1. sudo docker-compose up -d mysql nginx php-fpm workspace phpmyadmin
  2. docker-compose exec --user=laradock workspace bash
  3. composer create-project laravel/laravel blog

With the above commands I get error:

Creating a "laravel/laravel" project at "./blog" Installing laravel/laravel (v7.12.0) [ErrorException] mkdir(): Permission denied

Can anyone help me to setup laravel in laradock.


Solution

  • So after a bit of digging I found out that I need to run the following commands:

    *docker-compose exec workspace bash

    *chmod -R 777 project-folder/storage