Skip to content

Detached and interactive mode: -d, -i and -t

Select an icon to see what it is.

Step 2 of 6

-i keeps stdin open, -t adds a terminal

-i sets OpenStdin, AttachStdin and StdinOnce, so the container's stdin stays open for your keystrokes while you are attached. -t sets Tty, which gives the container a pseudo-terminal, so programs like a shell behave as if on a real screen. Together, -it is what lets you type into a shell.

$ docker run -it --rm alpine sh

POST /v1.45/containers/create

{
"Image": "alpine"
"Cmd": [
"sh"
]
"Tty": true
"OpenStdin": true
"StdinOnce": true
"AttachStdin": true
"AttachStdout": true
"AttachStderr": true
}