With docker it's possible to pipe data into a container like this:
$ (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:
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 is not set to true when a container is created. In fact, docker inspect-ing the nl container in the above example, I see:
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 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
As a work around, currently we use docker exec -i ... to feed the input data to a named pipe in the container. The container process will then redirect its STDIN from the named pipe.
With docker it's possible to pipe data into a container like this:
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:But, if you have a container that's configured to be
interactive
(specifically,interactive
istrue
andpseudoTerminal
isfalse
) via a task, you can not, later, on the host running the container,docker attach
to its STDIN. Doing so blocks thedocker attach
command and would not return.I suspect this is because the
AttachStdin
option in the create container API is not set totrue
when a container is created. In fact,docker inspect
-ing thenl
container in the above example, I see:However, for a container started by ECS, I see:
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