When would I use `--interactive` without `--tty` in a Docker container?

后端 未结 1 643
一个人的身影
一个人的身影 2020-12-08 09:39

I did some googling and have had no luck finding a case where I\'d run docker run -i some_image rather than docker run -it some_image.

If

相关标签:
1条回答
  • 2020-12-08 10:38

    Since -i keeps STDIN open even if not attached, it allows for composition (piping).
    For example:

    docker run ubuntu printf "line1\nline2\n" | docker run -i ubuntu grep line2 | docker run -i ubuntu sed 's/line2/line3/g'
    

    (Source: issue 14221)

    Or:

    $ echo hello | docker run -i busybox cat
      hello
    

    (Source: issue 12401)

    Now imagine this not in front of a keyboard and being used in a script where you can actually write to the processes stdin through something better than a shell |: example integration-cli/docker_cli_attach_test.go

    0 讨论(0)
提交回复
热议问题