Docker Community Forums

Share and learn in the Docker community.

Docker container port mapping 80:80 only works on localhost but not from external access?

Logged in my intranet server via SSH on IP (port 22 of course)

Created a docker-compose.yml:

version: '3.8'
    container_name: php-apache
    image: php:8.0-apache
      - ./php/src:/var/www/html/
      - 80:80

And in ./php/src I have index.php :

echo 123+123;

I use docker-compose up -d in the current directory, and the container is successfully started:

CONTAINER ID   IMAGE                    COMMAND                  CREATED          STATUS                    PORTS                               NAMES
9795a5fdd59f   php:8.0-apache           "docker-php-entrypoi…"   19 minutes ago   Up 19 minutes   >80/tcp, :::80->80/tcp   php-apache

Now if I use lynx http://localhost or lynx , it’s correctly returning:


As the web page. But when I try to access the server in Chrome, it keeps circling for a few seconds and then nothing (ERR_EMPTY_RESPONSE).

According to docs and some searches in Google, everything I did was correct?

What could be the problem here?