Cannot connect to netcat server in rootful mode on exposed port from host (`nc -l` exits immediately)
- Dominant language
- Go
- Stars
- 21.9k
- Forks
- 957
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 53
Description
### Description
When I try to connect to a netcat server running in a container through an exposed port from the host, I cannot connect to the server. This happens only in rootful mode.
Steps to reproduce
```
$ limactl shell default
$ sudo systemctl restart containerd.service
$ sudo nerdctl run -d -p 6000:80 alpine sh -c "echo hello | nc -l -p 80"
bef8a45ec555fbda8768bf613a162138a62ec6062b245efedadc92dda0af32d9
$ sudo nerdctl ps -a
bef8a45ec555 docker.io/library/alpine:latest "sh -c echo hello | …" 9 seconds ago Exited (0) 5 seconds ago 0.0.0.0:6000->80/tcp alpine-bef8a
```
nc server exits with exit code 0 without a client establishing a connection with it. Therefore running
```
nc localhost 6000
```
does not connect to the server running in the container and therefore does not receive the "hello".
This behavior is only observed in rootful mode, increasing the timeout by running `sudo nerdctl run -d -p 6000:80 alpine sh -c "echo hello | nc -l -p 80 -w 60"` does not help either and the connection is closed before 60 seconds.
Expected behavior: Running sudo nerdctl run -d -p 6000:80 alpine sh -c "echo hello | nc -l -p 80" should not exit until a client establishes a connection.
Host info: 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64 x86_64
Lima version:
```
lima -v
limactl version 0.12.1-rd1
```
Contributor guide
Assessment
This issue has not been assessed yet.