[ECS] [request]: Allow redirecting STDIN of a container
- Dominant language
- Shell
- Stars
- 5.4k
- Forks
- 334
- PR merge metrics
- No merged PRs in 30d
Description
With docker it's possible to pipe data into a container like this:
```bash
$ (echo hello; echo world) | docker run -i ubuntu nl
1 hello
2 world
$
```
However, in ECS, even though it's possible to configure a container to be `interactive` in its task definition, doing so does not allow one to later pipe data to it. For example, this is possible with docker:
```bash
$ docker run --name nl -i ubuntu nl >/dev/null 2>&1 &
[2] 22254
$ (echo hello; echo world) | docker attach nl
1 hello
2 world
[2]+ Done docker run --name nl -i ubuntu nl > /dev/null 2>&1
$
```
But, if you have a container that's configured to be `interactive` (specifically, `interactive` is `true` and `pseudoTerminal` is `false`) via a task, you can not, later, on the host running the container, `docker attach` to its STDIN. Doing so blocks the `docker attach` command and would not return.
I suspect this is because the `AttachStdin` option in the [create container API](https://docs.docker.com/engine/api/v1.41/#operation/ContainerCreate) is not set to `true` when a container is created. In fact, `docker inspect`-ing the `nl` container in the above example, I see:
```bash
$ docker inspect nl | grep Attach
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
```
However, for a container started by ECS, I see:
```
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
```
Is there a plan to make these options (maybe the `StdinOnce` options as well) configurable in a ECS task definition? It would be very convenient for our tooling to be able to pipe data to an one-off container in ECS this way, to avoid having to re-build the docker image to include the data, or having to get the data over the network, in which case we probably have to upload them somewhere first.
Thank you
### Community Note
* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment
Contributor guide
Research direction
Start with the ECS task-definition configuration described in the issue and compare it with Docker's ContainerCreate AttachStdin and StdinOnce options. Confirm how ECS currently maps interactive and pseudoTerminal settings, then define the task-definition behavior needed for host-side stdin attachment. Done means a configured ECS container accepts piped input through the supported attach workflow.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, docker
- Domain
- cloud, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100