Can’t Curl docker container running apache from outside the container

  curl, docker, php

I am not able to curl my php that is running Apache from the regular terminal.
Curling localhost inside the container returns the correct results.

docker-compose file:

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"]

the docker logs show a 500 error in the request(from outiside the container)

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.

Source: Docker Questions

LEAVE A COMMENT