`docker run -a stdin` confusing behaviour
Nobody has claimed this yet.
- Dominant language
- Markdown
- Stars
- 4.7k
- Forks
- 8.5k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 108
Description
File: engine/reference/commandline/run.md
Picking up from this slack thread https://dockercommunity.slack.com/archives/C7GKACWDV/p1649427806814209, the behaviour of docker run -a stdin seems is a bit confusing.
The current docker run docs show that the --interactive flag will "Keep STDIN open even if not attached". In order to attach STDIN without the --interactive flag, the docs show that --attach stdin is available.
The expectation was that docker run -a stdin -a stdout -a stderr busybox cat < foo.txt would be equivalent to docker run -i busybox cat < foo.txt. However, docker run without the -i flag but with stdin/stderr/stdout attached displays nothing to stdout.
After investigation, it looks historically like there was confusion about how --interactive would behave when -a stdin was not specified (https://github.com/moby/moby/pull/12401). There's some discussion across several issues (https://github.com/moby/moby/pull/14390, https://github.com/moby/moby/pull/14417) about whether there were use-cases for --interactive when stdin wasn't attached, with the conclusion that the right way to fix was to enforce that -a stdin is silently enforced whenever --interactive is specified.
My read here is that the initial use-case for the -a stdin flag was to pair with the --interactive flag (again, cf. this diff https://github.com/moby/moby/pull/12401/files), and that's always happening since PR 14417.
However, that leaves -a stdin now as a cli option without clear purpose. It appears to me that specifying docker run -a stdin -a stdout -a stderr busybox cat < foo.txt results in stdin being attached, then the handles are being detached before any output can happen. I expected the handles to be blocked open until after the command output is returned.
I'm not sure what the best docs fix here is; maybe -a stdin has use-cases that aren't obvious to me here? I'm happy to help answer questions as best I can to try and find a way to clarify the intended behaviour.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with engine/reference/commandline/run.md and reproduce the two docker run commands described in the issue using busybox and cat. Read the linked historical pull requests to establish the intended stdin behavior. Done means the documentation clearly explains the purpose and behavior of -a stdin, including whether the example should be changed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker
- Domain
- cli, documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100