新 api 平台 docker-compose 上的 502 错误网关

Mar*_*vák 1 php docker docker-compose bad-gateway api-platform.com

我在 Digital Ocean 上有 docker,并且仍在尝试弄清楚如何使用 api 平台。所以我在端口 80 上的 api-platform-2.3.0 默认页面中的 docker-compose up 正常加载,但是当我转到 8080 时,它显示了错误的网关。所以我查了一下一切是否加载正常,看来 PHP 有问题。

\n\n
CONTAINER ID        IMAGE                          COMMAND                  CREATED             STATUS                        PORTS                                                                    NAMES\n0a0c4724d2d5        api_h2-proxy                   "nginx -g \'daemon of\xe2\x80\xa6"   18 minutes ago      Up 18 minutes                 0.0.0.0:443-444->443-444/tcp, 80/tcp, 0.0.0.0:8443-8444->8443-8444/tcp   api_h2-proxy_1\n9958631ba1b8        quay.io/api-platform/varnish   "docker-varnish-entr\xe2\x80\xa6"   18 minutes ago      Up 18 minutes                 0.0.0.0:8081->80/tcp                                                     api_cache-proxy_1\n68de4a5058dd        quay.io/api-platform/nginx     "nginx -g \'daemon of\xe2\x80\xa6"   18 minutes ago      Up 18 minutes                 0.0.0.0:8080->80/tcp                                                     api_api_1\nf805ffdd804d        quay.io/api-platform/php       "docker-entrypoint p\xe2\x80\xa6"   18 minutes ago      Exited (126) 18 minutes ago                                                                            api_php_1\nb020f888b81d        postgres:9.6-alpine            "docker-entrypoint.s\xe2\x80\xa6"   19 minutes ago      Up 19 minutes                 0.0.0.0:5432->5432/tcp                                                   api_db_1\n1f86200d43bd        quay.io/api-platform/admin     "/bin/sh -c \'yarn st\xe2\x80\xa6"   19 minutes ago      Up 18 minutes                 0.0.0.0:81->3000/tcp                                                     api_admin_1\n6986bf74b501        quay.io/api-platform/client    "/bin/sh -c \'yarn st\xe2\x80\xa6"   19 minutes ago      Up 18 minutes                 0.0.0.0:80->3000/tcp                                                     api_client_1\n
Run Code Online (Sandbox Code Playgroud)\n\n

并且 docker-compose up 没有 -d 标志

\n\n
root@restApi:/usr/api# docker-compose up\nCreating api_admin_1       ... done\nCreating api_php_1         ... done\nCreating api_client_1      ... done\nCreating api_api_1         ... done\nCreating api_php_1         ...\nCreating api_cache-proxy_1 ... done\nCreating api_cache-proxy_1 ...\nCreating api_h2-proxy_1    ... done\nAttaching to api_db_1, api_php_1, api_api_1, api_cache-proxy_1, api_admin_1, api                                                                                  _client_1, api_h2-proxy_1\ndb_1           | LOG:  database system was shut down at 2018-07-12 04:32:08 UTC\ndb_1           | LOG:  MultiXact member wraparound protections are now enabled\ndb_1           | LOG:  database system is ready to accept connections\ndb_1           | LOG:  autovacuum launcher started\nphp_1          | Loading composer repositories with package information\nphp_1          | Installing dependencies (including require-dev) from lock file\nphp_1          | Nothing to install or update\nphp_1          | Generating autoload files\nphp_1          | Executing script cache:clear [OK]\nphp_1          | Executing script assets:install [OK]\nphp_1          | Waiting for Postgres to be ready...\nphp_1          |\nphp_1          | /usr/local/bin/docker-entrypoint: line 22: bin/console: Permiss                                                                                   ion denied\nphp_1          | db:5432 - accepting connections\napi_php_1 exited with code 126\ncache-proxy_1  | Debug: Platform: Linux,4.4.0-130-generic,x86_64,-junix,-smalloc                                                                                   ,-sdefault,-hcritbit\ncache-proxy_1  | Debug: Child (18) Started\ncache-proxy_1  | Info: Child (18) said Child starts\nadmin_1        | yarn run v1.5.1\nadmin_1        | $ react-scripts start\nclient_1       | yarn run v1.5.1\nclient_1       | $ react-scripts start\nadmin_1        | Starting the development server...\nadmin_1        |\nclient_1       | Starting the development server...\nclient_1       |\nclient_1       | Compiled successfully!\nclient_1       |\nclient_1       | You can now view client in the browser.\nclient_1       |\nclient_1       |   Local:            http://localhost:3000/\nclient_1       |   On Your Network:  http://172.18.0.6:3000/\nclient_1       |\nclient_1       | Note that the development build is not optimized.\nclient_1       | To create a production build, use yarn build.\nclient_1       |\nadmin_1        | Compiled successfully!\nadmin_1        |\nadmin_1        | You can now view admin in the browser.\nadmin_1        |\nadmin_1        |   Local:            http://localhost:3000/\nadmin_1        |   On Your Network:  http://172.18.0.3:3000/\nadmin_1        |\nadmin_1        | Note that the development build is not optimized.\nadmin_1        | To create a production build, use yarn build.\nadmin_1        |\napi_1          | 2018/07/12 04:35:13 [error] 5#5: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 80.9                         5.103.67, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.3:9000", host: "restapi.my:8080"\napi_1          | 80.95.103.67 - - [12/Jul/2018:04:35:13 +0000] "GET / HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) App                         leWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" "-"\napi_1          | 80.95.103.67 - - [12/Jul/2018:04:35:13 +0000] "GET /favicon.ico HTTP/1.1" 200 32038 "http://restapi.my:8080/" "Mozilla/5.                         0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" "-"\napi_1          | 2018/07/12 04:35:21 [error] 5#5: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 80.9                         5.103.67, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.3:9000", host: "restapi.my:8080"\napi_1          | 80.95.103.67 - - [12/Jul/2018:04:35:21 +0000] "GET / HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) App                         leWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" "-"\napi_1          | 2018/07/12 04:36:01 [error] 5#5: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 80.9                         5.103.67, server: , request: "GET / HTTP/1.1", upstream: "fastcgi://172.18.0.3:9000", host: "restapi.my:8080"\napi_1          | 80.95.103.67 - - [12/Jul/2018:04:36:01 +0000] "GET / HTTP/1.1" 502 575 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) App                         leWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36" "-"\n
Run Code Online (Sandbox Code Playgroud)\n\n

正如你所看到的,php 显示错误 126,我猜这不正常,我有 Composer 和 php v.7.0.3

\n\n

谢谢你的帮助。

\n\n

ps 我知道网关 503 上有类似的问题,但我的是干净的 Api 平台,构建没有帮助。

\n

Mar*_*vák 5

问题是 api/bin/console 无法执行,正如 @K\xc3\xa9vin Dunglas 提到的那样。解决办法很简单,只需chmod 755 console。就是这样。

\n