Docker's `--publish-all` option doesn't work when running a .NET container
- Dominant language
- Dockerfile
- Stars
- 4.9k
- Forks
- 2k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 26
Description
The `docker run` command has a `-P, --publish-all` option which publishes all the exposed ports of the image to random ports on the host. But since the .NET Dockerfiles don't have an `EXPOSE` instruction, Docker doesn't know what ports to publish and so publishes none.
Repro
```bash
$ docker run --name test1 -it -P mcr.microsoft.com/dotnet/samples:aspnetapp
$ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e689fb5690a6 mcr.microsoft.com/dotnet/samples:aspnetapp "./aspnetapp" 16 minutes ago Up 16 minutes (healthy) test1
```
Notice that PORTS is empty in the output above.
If an instruction like this existed in the .NET Dockerfile:
```Dockerfile
EXPOSE 80
```
The output would look like this:
```
❯ docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
abd4a78f1b09 mcr.microsoft.com/dotnet/samples:aspnetapp "./aspnetapp" 27 seconds ago Up 26 seconds (health: starting) 0.0.0.0:32768->80/tcp test1
```
Contributor guide
Assessment
This issue has not been assessed yet.