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 10.10.245.209 (port 22 of course)

Created a docker-compose.yml:

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

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

<?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             0.0.0.0:80->80/tcp, :::80->80/tcp   php-apache

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

246

As the web page. But when I try to access the server http://10.10.245.209 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?