cannot access service from another service from docker-compose

I am having below docker-compose script

version: '3.1'

services:
  generator:
    image: my-registry:55000/gen:ci-8
    ports: 
      - "8080:80"
  mail:
    image: mailhog/mailhog
    ports: 
      - "8025:8025"
  integration:
    image: my-registry:55000/gen:integration-9
    build: .

from integration service, I am calling generator service as below

public const string GeneratorApiRoot = "http://generator:80";
var client = new HttpClient();
var sendEmail = new HttpRequestMessage
{
    Method = HttpMethod.Post,
    RequestUri = new Uri($"{GeneratorApiRoot}/EmailRandomNames")
};

using (var response = await client.SendAsync(sendEmail))
{
   response.EnsureSuccessStatusCode();
}

I am getting status code 404 not found error msg. But when I access from host with http://localhost:8080/EmailRandomNames I am getting 200 status code.

What am I doing wrong? Please help.

Source: StackOverflow