Skip to content

[FAQ] What's the difference between i and t in docker run -it? #107

@elcapo

Description

@elcapo

Course

data-engineering-zoomcamp

Question

What's the difference between i and t in docker run -it?

Answer

When running containers interactively, Docker provides two commonly used flags: -i (interactive) and -t (tty). They are often used together as -it, but they serve different purposes.

  • -i keeps the container’s STDIN open, even if it is not attached to a terminal. This allows you send input to the process running inside the container.
echo "print(2+2)" | docker run -i python
  • -t allocates a pseudo-terminal (TTY) for the container. This provides proper terminal formatting (line breaks, colors, prompts).
docker run -t ubuntu date

Using both flags together gives you 1) an open input stream and 2) a real terminal interface. This is what you normally want for an interactive shell session.

docker run -it ubuntu bash

Checklist

  • I have searched existing FAQs and this question is not already answered
  • The answer provides accurate, helpful information
  • I have included any relevant code examples or links

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions