Differences between docker -i -t and -it flags

Viewed 1530

I'm a little confused by some docker flags, and more particularly by the "i", "t" and "it" flags.

First, is "docker run -it" equivalent to "docker run -i -t" ?

Second, what does "Allocate a pseudo-TTY" exactly means (it is the documentation of the "-t" flag) ?

I've conducted a couple of tests with an image (called hello-world) having

CMD ["echo", "Hello docker world !!!"]

or

ENTRYPOINT  ["echo", "Hello docker world !!!"]

The following commands :

  • docker run -i -t hello-world
  • docker run -i hello-world
  • docker run -t hello-world
  • docker run -it hello-world
  • docker run hello-world

all resulted in the display of the text "Hello world". I would expect at least the last one to not display anything...

2 Answers

Those are called flags and a flag can either be combined or separated, either in short (-) or long format (--). So:

docker run --interactive --tty hello-world

docker run --interactive -t hello-world

docker run -i --tty hello-world

docker run -i -t hello-world

docker run -it hello-world

are all the same.

As to how -i and -t works, refer to this

Related