Repository: deno
Issue: Within docker, deno `socket.connect` `underscore_hostname` syscall `getaddrinfo` fail with `ENOTFOUND`
Labels: bug,node compat

# BUG

Within docker

- node `socket.connect` `underscore_hostname` OK

- node `socket.connect` `hyphen-hostname` OK

- deno `socket.connect` `underscore_hostname` syscall `getaddrinfo` fail with `ENOTFOUND`

- deno `socket.connect` `hyphen-hostname` OK

## version

- node v21.7.1

- deno 1.42.0

## prepare

`foo/docker-compose.yml`

Containers with connectable `underscore_hostname` and `hyphen-hostname` listening on port 1234.

<details>
  <summary markdown="span">code</summary>

```yml
networks:
  foo:
    external: true

services:
  underscore:
    image: python
    hostname: underscore_hostname
    networks:
      - foo
    command: python -m http.server 1234

  hyphen:
    image: python
    hostname: hyphen-hostname
    networks:
      - foo
    command: python -m http.server 1234
```

</details>

`bar/docker-compose.yml`

Run reproduce code using `node` and `deno`.

<details>
  <summary markdown="span">code</summary>

```yml
networks:
  foo:
    external: true

services:
  node:
    image: node
    networks:
      - foo
    command: bash -c 'node --version && node reproduce.mjs'
    volumes:
      - './reproduce.mjs:/reproduce.mjs'

  deno:
    image: denoland/deno
    networks:
      - foo
    command: bash -c 'deno --version && deno run -A ./reproduce.mjs'
    volumes:
      - './reproduce.mjs:/reproduce.mjs'
```

</details>

`bar/reproduce.mjs`

Logic extracted from [pg@8.11.3](https://github.com/brianc/node-postgres/blob/pg%408.11.3/packages/pg/lib/connection.js#L44)

Connect to `underscore_hostname` and `hyphen-hostname`.

<details>
  <summary markdown="span">code</summary>

```js
import { Socket } from 'node:net'

const RUNNER = typeof Deno === 'undefined' ? 'node' : 'deno'

for (const el of ['underscore_hostname', 'hyphen-hostname']) {
  await new Promise((resolve, _reject) => {
    const socket = new Socket()
    socket.connect(1234, el)

    socket.on('connect', () => {
      console.debug(`[OK] ${RUNNER} ${el}`)

      socket.destroy()
      resolve()
    })
    socket.on('error', (err) => {
      console.error(`[ERR] ${RUNNER} ${el}`)
      console.error(err)

      resolve()
    })
  })
}
```

</details>

## actual

Within docker

- node `socket.connect` `underscore_hostname` OK

- node `socket.connect` `hyphen-hostname` OK

- deno `socket.connect` `underscore_hostname` syscall `getaddrinfo` fail with `ENOTFOUND`

- deno `socket.connect` `hyphen-hostname` OK

```sh
$ docker network create foo
...
$ env -C foo docker-compose up --remove-orphans --force-recreate
...
```

```sh
$ env -C bar docker-compose up --remove-orphans --force-recreate
deno-1  | deno 1.42.0 (release, x86_64-unknown-linux-gnu)
deno-1  | v8 12.3.219.9
deno-1  | typescript 5.4.3
node-1  | v21.7.1
node-1  | [OK] node underscore_hostname
node-1  | [OK] node hyphen-hostname
deno-1  | [ERR] deno underscore_hostname
deno-1  | Error: getaddrinfo ENOTFOUND underscore_hostname
deno-1  |     at __node_internal_captureLargerStackTrace (ext:deno_node/internal/errors.ts:91:9)
deno-1  |     at __node_internal_ (ext:deno_node/internal/errors.ts:244:10)
deno-1  |     at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:37:26)
deno-1  |     at ext:deno_node/internal_binding/cares_wrap.ts:78:9 {
deno-1  |   errno: -3007,
deno-1  |   code: "ENOTFOUND",
deno-1  |   syscall: "getaddrinfo",
deno-1  |   hostname: "underscore_hostname"
deno-1  | }
deno-1  | [OK] deno hyphen-hostname
node-1 exited with code 0
deno-1 exited with code 0
```

## expected

- deno `socket.connect` `underscore_hostname` OK