Naveed
Naveed

Reputation: 726

How to get the output from docker run -i

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?

Upvotes: 15

Views: 22159

Answers (1)

Naveed
Naveed

Reputation: 726

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.

Upvotes: 16

Related Questions