Home > database >  Differences between docker -i -t and -it flags [duplicate]
Differences between docker -i -t and -it flags [duplicate]

Time:10-08

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...

CodePudding user response:

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

CodePudding user response:

In this above simple example it will work the same.

In the last example container will print "Hello..." and exit in contrary to when you start interactive mode: https://phoenixnap.com/kb/docker-run-command-with-examples (-i -t -it will work the same)

For the difference cmd and entrypoint refer here: What is the difference between CMD and ENTRYPOINT in a Dockerfile?

  • Related