2

This post fleshes most of this out: Confused about Docker -t option to Allocate a pseudo-TTY

But if "-i" gives me a stdin stream and -t gives me a whole terminal driver isn't -i redundant if I use them together? Or is it that with just -t I can only access it via ssh but if I add -i I can also pipe it input directly from the console?

red888
  • 27,709
  • 55
  • 204
  • 392

1 Answers1

1

I remember reading about it a while ago in the documentation. I had a look and I found:

For interactive processes (like a shell), you must use -i -t together in order to allocate a tty for the container process. -i -t is often written -it as you’ll see in later examples. Specifying -t is forbidden when the client is receiving its standard input from a pipe, as in:

In the documentation. I use --ti a lot and always write it as ti, I guess thats why a google search yields little result. The documentation mentions it a lot but not once mentions ti


The technical side of things

The OP asked me to go into a bit more detail so here it is...

The -i flag means "interactive" (replaceable with --interactive as well). This basically means that the shell will remain open even if it has nothing to do. (e.g waiting for user input).

An example of an interactive shell would be a standard terminal window / command prompt. It will stay open and wait for your input (e.g interaction), upon receiving input it executes a task.

An example of a non-interactive shell would be a simple bash script. The script will run but won't offer any interaction with the shell. (although it's possible to emulate an interactive shell with the read statement.

Specifying -t without -i would therefor mean that the tty would immediatelly disband, seeing as it wouldn't actually "run" anything and since you didn't start it interactively it won't wait for your input.

More info about interactive vs non-interactive can be found here.

Rick van Lieshout
  • 2,276
  • 2
  • 22
  • 39