Closed ibrahimbayyinah closed 8 months ago
I managed to solve this (with the help of ChatGPT) by opening a shell inside the container and manually changing the ownership of the .env
file (below I outline the steps for those who face the same problem and want a quick fix).
However, I wonder if this is the best solution. I am running it locally now, so there are no security concerns. But is this solution still good if I were to run it on a VPS? In other words: would it be a potential problem if the owner of the .env
file is the web server user (www-data
)?
Steps of the quick fix:
docker exec -it servas sh
./var/www/html/
. The .env
file is in that directory.www-data
(the web server user): chown www-data:www-data /var/www/html/.env
.exit
command.docker exec -it servas php artisan key:generate --force
and follow the rest of the installation steps.Thank you for the detailed bug report.
I have tried to reproduce your described permission issue. However, it worked on my local machine.
I cannot say what is the problem here, maybe it has something to do with how you installed Docker.
Can you install Servas again? And after the first docker compose up -d
, can you enter the container with docker exec -it servas bin/sh
and check the owner and file permissions of the .env
file?
Hey beromir, thanks for your quick reply. I honestly thought I'd have to wait several days and I appreciate your willingness to help! I'm sorry if I'm late to reply, but I currently have exams, so I don't check github as often.
That said, it's owned by 1000:1000
and has read-write
permissions for the owner and read
for everyone else (see output below).
/var/www/html # ls -l .env
-rw-r--r-- 1 1000 1000 348 Jan 21 08:29 .env
Also, minor point: I think you forgot the first slash in /bin/sh
. For me, bin/sh
didn't work. I had to use /bin/sh
.
Faced the same issue! Permissions are exactly how Ibrahim describes for me too!
I was able to reproduce the error. The problem is the different file ownership on the host machine.
To generate the application key, just run docker exec -it -u 1000 servas php artisan key:generate --force
on the host. This step is required only once, so you should be fine after that.
When running
docker exec -it servas php artisan key:generate --force
I get the following error:Steps to reproduce:
docker-compose.yaml
and.env
respectively..env
(see contents of both files below).docker-compose up -d
successfully. I get the following output:docker exec -it servas php artisan key:generate --force
, which gives the above mentioned error.I tried with the SQLite container and got the same problem.
I also tried several approaches, like:
docker-compose.yaml
and.env
and rundocker-compose up -d
from within thedocker
directory anddocker/sql-example
directory respectively..env
to777
(to make it readable, writeable and even executable by everyone).docker-compose.yaml
and.env
, like: giving the full path instead of./.env
in thevolumes
section ofdocker-compose.yaml
.Unfortunately, nothing was able to solve the problem. Reading from the error, I assume it's a problem with the
.env
file not being writeable in the container, however I am not familiar enough with containers and PHP/Laravel to be able to solve it on my own. I'd love to use this bookmarks manager as it seems to be the only one I found which meets my needs (self-hosted + nested groups). Thanks in advance for your time to help me solve this..env
content:docker-compose.yaml
(it's identical to the default):General info about my system: