markshust / docker-magento

Mark Shust's Docker Configuration for Magento
https://m.academy/courses/set-up-magento-2-development-environment-docker/
MIT License
2.54k stars 997 forks source link

The file "/var/www/.composer/config.json" is not readable. #1065

Closed vhdmoradi closed 7 months ago

vhdmoradi commented 7 months ago

Description I installed Docker-magento following the instructions and using the one-liner command. Alongside, I also installed docker-desktop to manage hardware distribution. Now, whenever I use docker-desktop dashboard to run the containers, everything works just fine with no problem. But I only have 8 GBs of Ram and a second generation core i5 intel CPU, so, I decided to use bin/start command to run the containers. This is where the problem occurs.

Steps To Reproduce When I run bin/start, it creates and starts all the containers, but giving this error at the end:

 [+] Running 8/8
    ✔ Container magento-mailcatcher-1  Started                                                                                                  0.0s 
    ✔ Container magento-opensearch-1   Healthy                                                                                                  0.0s 
    ✔ Container magento-rabbitmq-1     Healthy                                                                                                  0.0s 
    ✔ Container magento-redis-1        Healthy                                                                                                  0.0s 
    ✔ Container magento-db-1           Healthy                                                                                                  0.0s 
    ✔ Container magento-phpfpm-1       Started                                                                                                 44.6s 
    ✔ Container magento-phpmyadmin-1   Started                                                                                                  0.0s 
    ✔ Container magento-app-1          Started                                                                                                 44.9s 
   Installing devtools metapackage, just a moment...

   In JsonFile.php line 204:

     The file "/var/www/.composer/config.json" is not readable.  

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>...]

Devtools installed.

Even though, when I run the bin/status, i get:

NAME                    IMAGE                                 COMMAND                  SERVICE       CREATED         STATUS                        PORTS
magento-app-1           markoshust/magento-nginx:1.18-8       "/docker-entrypoint.…"   app           2 minutes ago   Up 32 seconds (healthy)       80/tcp, 0.0.0.0:80->8000/tcp, :::80->8000/tcp, 0.0.0.0:443->8443/tcp, :::443->8443/tcp
magento-db-1            mariadb:10.6                          "docker-entrypoint.s…"   db            12 hours ago    Up About a minute (healthy)   0.0.0.0:3306->3306/tcp, :::3306->3306/tcp
magento-mailcatcher-1   sj26/mailcatcher                      "mailcatcher --foreg…"   mailcatcher   12 hours ago    Up About a minute (healthy)   1025/tcp, 0.0.0.0:1080->1080/tcp, :::1080->1080/tcp
magento-opensearch-1    markoshust/magento-opensearch:2.5-1   "./opensearch-docker…"   opensearch    12 hours ago    Up About a minute (healthy)   0.0.0.0:9200->9200/tcp, :::9200->9200/tcp, 9600/tcp, 0.0.0.0:9300->9300/tcp, :::9300->9300/tcp, 9650/tcp
magento-phpfpm-1        markoshust/magento-php:8.2-fpm-0      "docker-php-entrypoi…"   phpfpm        2 minutes ago   Up 33 seconds                 9000/tcp
magento-phpmyadmin-1    linuxserver/phpmyadmin                "/init"                  phpmyadmin    12 hours ago    Up About a minute             443/tcp, 0.0.0.0:8080->80/tcp, :::8080->80/tcp
magento-rabbitmq-1      markoshust/magento-rabbitmq:3.11-1    "docker-entrypoint.s…"   rabbitmq      12 hours ago    Up About a minute (healthy)   4369/tcp, 5671/tcp, 0.0.0.0:5672->5672/tcp, :::5672->5672/tcp, 15671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp, :::15672->15672/tcp
magento-redis-1         redis:7.0-alpine                      "docker-entrypoint.s…"   redis         12 hours ago    Up About a minute (healthy)   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp

Which shows that apparently everything is fine. But upon trying to access the website throught the magento.test url, nginx gives me 404 error. While when used with docker-desktop, it works just fine.

YevhenZvieriev commented 7 months ago

Hi, @vhdmoradi

I am helping you.

This happens because the ~/.composer folder owner is root. When copied to the container it still has the root owner.

Can I ask, if you executed one-liner as root? If yes, you made a mistake. Composer should never be owned by root, on Linux, Mac, or anywhere else.

I suggest you execute bin/fixowns and bin/fixperms, it will resolve your problem.

markshust commented 7 months ago

Yes, what @YevhenZvieriev said, the ~/.composer directory on your host machine should never be owned by root. I'd suggest correcting the ownerships on this directory (and recursively, so none of the files and folders underneath it are also owned by root), and restart the containers afterwards which should correct your issue.

vhdmoradi commented 7 months ago

Thank you both for the answer, I ran both the commands, it did solve the previous error, but a new one occurred now. After I ran the commands, I ran the bin/restart command, and this is the result:

victor@pop-os:~/Sites/magento$ bin/restart
[+] Stopping 8/8
 ✔ Container magento-phpmyadmin-1   St...                                  4.2s 
 ✔ Container magento-mailcatcher-1  S...                                   1.3s 
 ✔ Container magento-app-1          Stopped                                1.3s 
 ✔ Container magento-phpfpm-1       Stoppe...                              0.4s 
 ✔ Container magento-rabbitmq-1     Stop...                                6.7s 
 ✔ Container magento-redis-1        Stopped                                0.4s 
 ✔ Container magento-opensearch-1   St...                                 10.6s 
 ✔ Container magento-db-1           Stopped                                0.7s 
[+] Running 8/8
 ✔ Container magento-rabbitmq-1     Heal...                                0.0s 
 ✔ Container magento-redis-1        Healthy                                0.0s 
 ✔ Container magento-db-1           Healthy                                0.0s 
 ✔ Container magento-phpmyadmin-1   St...                                  0.0s 
 ✔ Container magento-opensearch-1   He...                                  0.0s 
 ✔ Container magento-phpfpm-1       Starte...                              0.0s 
 ✔ Container magento-app-1          Started                                0.0s 
 ✔ Container magento-mailcatcher-1  S...                                   0.0s 
Installing devtools metapackage, just a moment...

In CurlDownloader.php line 372:

  curl error 28 while downloading https://repo.packagist.org/p2/markshust/mag  
  ento2-metapackage-devtools-cli.json: Operation timed out after 10025 millis  
  econds with 0 out of 0 bytes received                                        
  require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>...]

Devtools installed.
YevhenZvieriev commented 7 months ago

Check your internet connection, and make sure you have internet access and can upload files

Try running the bin/restart command again, as this may be a temporary issue.

vhdmoradi commented 7 months ago

Yep that was it