### Is there an existing issue for this?

- [X] I have searched the existing issues

### Current Behavior

I am using below docker-compose file to start the localstack container with es service
```
version: "3"
services:
  wiremock:
    image: "rodolpheche/wiremock"
    ports:
      - "8080"
  localstack:
    image: "localstack/localstack-full:0.14.2"
    ports:
      - "4566"
      - "4510:4510"
    environment:
      AWS_ACCESS_KEY_ID: "local-access-key-id"
      AWS_SECRET_ACCESS_KEY: "local-secret-access-key"
      HOSTNAME_EXTERNAL: "localstack"
      OPENSEARCH_ENDPOINT_STRATEGY: "port"
      SERVICES: "es"
      EDGE_PORT: "4566"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"

```

running `aws --region ap-south-1 --endpoint-url http://localstack:4566 es create-elasticsearch-domain --domain-name my-domain` to create domain
this command is returning `localhost:4510` as an endpoint, I am able to curl `curl localhost:4510` within localstack bash but 
neither on the host machine nor in `wiremock` container.



### Expected Behavior

I should able to access elastic search domain in host machine as well in another container

### How are you starting LocalStack?

With a docker-compose file

### Steps To Reproduce

#### How are you starting localstack

 ```
version: "3"
services:
  wiremock:
    image: "rodolpheche/wiremock"
    ports:
      - "8080"
  localstack:
    image: "localstack/localstack-full:0.14.2"
    ports:
      - "4566"
      - "4510:4510"
    environment:
      AWS_ACCESS_KEY_ID: "local-access-key-id"
      AWS_SECRET_ACCESS_KEY: "local-secret-access-key"
      HOSTNAME_EXTERNAL: "localstack"
      OPENSEARCH_ENDPOINT_STRATEGY: "port"
      SERVICES: "es"
      EDGE_PORT: "4566"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock"

```

#### Client commands

    aws --region ap-south-1 --endpoint-url http://localstack:4566 es create-elasticsearch-domain --domain-name my-domain


### Environment

```markdown
- OS:
- LocalStack:
```


### Anything else?

_No response_
domain_key: DomainKey,
    custom_endpoint: Optional[CustomEndpoint] = None,
    engine_type: EngineType = EngineType.OpenSearch,
    preferred_port: Optional[int] = None,
) -> str:
    """
    Builds the cluster endpoint from and optional custom_endpoint and the localstack opensearch config. Example
    values:
    - my-domain.us-east-1.opensearch.localhost.localstack.cloud:4566 (endpoint strategy = domain (default))
    - localhost:4566/us-east-1/my-domain (endpoint strategy = path)
    - localhost:[port-from-range] (endpoint strategy = port (or deprecated 'off'))
    - my.domain:443/foo (arbitrary endpoints (technically not allowed by AWS, but there are no rules in localstack))
    If preferred_port is not None, it is tried to reserve the given port. If the port is already bound, another port
    will be used.
    """
    
    if custom_endpoint and custom_endpoint.enabled:
        return custom_endpoint.endpoint
    
    engine_domain = "opensearch" if engine_type == EngineType.OpenSearch else "es"
    
    if config.OPENSEARCH_ENDPOINT_STRATEGY == "port":
        if preferred_port is not None:
            try: