How to get permissions for /var/www/html at laravel sail containers? #58226
-
|
Hello. 2 days ago i created blank laravel project installed sail. When i run sail up command i got next errors. WARN[0000] No services to build
[+] up 2/2
✔ Container to-do-pgsql-1 Recreated 0.2s
✔ Container to-do-laravel.test-1 Recreated 0.1s
Attaching to laravel.test-1, pgsql-1
pgsql-1 | ls: /docker-entrypoint-initdb.d/10-create-testing-database.sql: Permission denied
pgsql-1 exited with code 1
laravel.test-1 | 2025-12-29 08:00:59,662 INFO Set uid to user 0 succeeded
laravel.test-1 | 2025-12-29 08:00:59,665 INFO supervisord started with pid 1
laravel.test-1 | 2025-12-29 08:01:00,667 INFO spawned: 'php' with pid 16
laravel.test-1 | Could not open input file: /var/www/html/artisan
laravel.test-1 | 2025-12-29 08:01:00,729 WARN exited: php (exit status 1; not expected)
laravel.test-1 | 2025-12-29 08:01:01,731 INFO spawned: 'php' with pid 17
laravel.test-1 | Could not open input file: /var/www/html/artisan
laravel.test-1 | 2025-12-29 08:01:01,797 WARN exited: php (exit status 1; not expected)
laravel.test-1 | 2025-12-29 08:01:03,800 INFO spawned: 'php' with pid 18
laravel.test-1 | Could not open input file: /var/www/html/artisan
laravel.test-1 | 2025-12-29 08:01:03,845 WARN exited: php (exit status 1; not expected)
laravel.test-1 | 2025-12-29 08:01:06,850 INFO spawned: 'php' with pid 19
laravel.test-1 | Could not open input file: /var/www/html/artisan
laravel.test-1 | 2025-12-29 08:01:06,910 WARN exited: php (exit status 1; not expected)
laravel.test-1 | 2025-12-29 08:01:07,911 INFO gave up: php entered FATAL state, too many start retries too quicklyIn my first try i run sail in podman in when i got this error i thought it is podman problems. I installed docker and tried another time i got that error again. First I tried to ls /var/www/html as a sail user in container I got Permission denied. And also I tried to ls /var/www/html as a root in container, and I got Permission denied. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
this looks like selinux or apparmor blocking docker from accessing your files. try this: # check if selinux is enabled
getenforce
# if it shows Enforcing, try:
sudo setenforce 0
sail upif that works, selinux was the problem. for permanent fix: # add :z flag to volume in docker-compose.yml
volumes:
- .:/var/www/html:zor you can disable selinux for docker: sudo setsebool -P container_manage_cgroup onalso check your project folder permissions: ls -la /path/to/your/project
# should be owned by your user (uid 1000)let me know if this helps |
Beta Was this translation helpful? Give feedback.
-
|
This looks like a bind mount permission issue, pretty common on Linux with Docker. The problem is that your host files are mounted into the container but the container user cannot read them. Here is how to fix: 1. Check your project folder permissions on host: ls -la /path/to/your/laravel-project2. If permissions are wrong, fix them: # Give read/write to your user
sudo chown -R $USER:$USER /path/to/your/laravel-project
chmod -R 755 /path/to/your/laravel-project3. For the PostgreSQL init script error: chmod 644 docker/pgsql/create-testing-database.sql4. If still not working, try rebuilding: ./vendor/bin/sail down -v
./vendor/bin/sail build --no-cache
./vendor/bin/sail upThis usually happens when the project was created as root or copied from another machine. Let me know if this helps! |
Beta Was this translation helpful? Give feedback.
this looks like selinux or apparmor blocking docker from accessing your files.
try this:
if that works, selinux was the problem. for permanent fix:
# add :z flag to volume in docker-compose.yml volumes: - .:/var/www/html:zor you can disable selinux for docker:
also check your project folder permissions:
ls -la /path/to/your/project # should be owned by your user (uid 1000)let me know if this helps