簡體   English   中英

不能 Curl docker 容器從容器外部運行 apache

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

我無法 curl 我的 php 從常規終端運行 Apache。 在容器內卷曲 localhost 會返回正確的結果。

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

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

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”

但是卷曲一個測試文件(位於與 gateway.php 相同的文件夾中,其中包含一個回顯會返回 output。

嘗試在端口旁邊添加 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