How to get the output from docker run -i
Asked Answered
M

1

15

docker run normally returns the output of the command it runs. I need to pass some data to docker, run a command that processes the data, and return the output. When I use the -i option, no output is returned. Consider this simple example:

echo hello | docker run -i base wc

It returns no output. How can I get the output from docker when using the -i option?

Manners answered 26/4, 2013 at 9:8 Comment(2)
Could you add the output of docker version? I suspect this is a bug in whatever version you're running.Moresque
@Moresque cant get output on 0.5.0Presentation
M
16

The solution I came up with is:

ID=$(echo hello | docker run -i -a stdin base wc)
docker logs $ID

I'm not sure if this is the best way, but it works.

Manners answered 3/5, 2013 at 21:30 Comment(1)
Great solution!Marthamarthe

© 2022 - 2024 — McMap. All rights reserved.