1 year ago
#380441

Zachary
Cannot pipe to docker run with stdin attached
I am newbie on Docker. Seems the following pipe prints nothing. If I am right, the -a stdin
attaches my host stdin to the container process's stdin.
~ $ echo test | docker run -a stdin -a stdout -a stderr --rm alpine cat -
When I add the -i
option, it does print the "test":
~ $ echo test | docker run -i -a stdin -a stdout -a stderr --rm alpine cat -
test
Why must we append the -i
option?
I did read this post Confused about Docker -t option to Allocate a pseudo-TTY, but still confused by options like -a, -d, -t, -i
. For example, is there any difference between the following two runs?
~ $ docker run -a stdin -a stdout -it ubuntu /bin/bash
~ $ docker run -it ubuntu /bin/bash
After some search, I think the -i
option's purpose is to make the stdin of PID 1 open which by default is closed.
bash
docker
containers
pipe
0 Answers
Your Answer