简体   繁体   English

不能 Curl docker 容器从容器外部运行 apache

[英]Can't Curl docker container running apache from outside the container

I am not able to curl my php that is running Apache from the regular terminal.我无法 curl 我的 php 从常规终端运行 Apache。 Curling localhost inside the container returns the correct results.在容器内卷曲 localhost 会返回正确的结果。

docker-compose file: docker-compose 文件:

version: '3'
services:
dash-api:
 build:
  context: .
  dockerfile: Dockerfile
  args:
    - GITHUB_HTTPS_TOKEN=<token>

 volumes:
   - /usr/local/:/usr/local/
   - /app:/var/www/html
 ports:
   - "80:80"

Dockerfile Dockerfile

FROM php:7.2.34-apache AS serve
...
EXPOSE 80
CMD ["apachectl", "-D", "FOREGROUND"]

the docker logs show a 500 error in the request(from outiside the container) docker 日志在请求中显示 500 错误(来自容器外部)

127.0.0.1 - - [25/Nov/2021:12:05:46 +0000] "GET /gateway.php HTTP/1.1" 500 1047 "-" "curl/7.54.0" 127.0.0.1 - - [25/Nov/2021:12:05:46 +0000]“GET /gateway.php HTTP/1.1”500 1047“-”“curl/7.54.0”

But curling a test file(located in the same folder as gateway.php with a single echo in it returns the output.但是卷曲一个测试文件(位于与 gateway.php 相同的文件夹中,其中包含一个回显会返回 output。

Try to add localhost next to port, maybe that will help.尝试在端口旁边添加 localhost,也许这会有所帮助。

version: '3'
services:
dash-api:
 build:
  context: .
  dockerfile: Dockerfile
  args:
    - GITHUB_HTTPS_TOKEN=<token>

 volumes:
   - /usr/local/:/usr/local/
   - /app:/var/www/html
 ports:
   - 127.0.0.1:80:80

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM