Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
557 views
in Technique[技术] by (71.8m points)

dockerfile - what is docker run -it flag?

I was doing some complex stuff with docker, but as turn out I don't know what -it flag means. Recently I've come across on some example of docker run command which has confused me a little.

docker run -itd ubuntu:xenial /bin/bash 

My question is what is sense to write -it flag here, if container during instantiation run bin/bash

In documentation we have an example

docker run --name test -it debian

with explanation

The -it instructs Docker to allocate a pseudo-TTY connected to the container’s stdin; creating an interactive bash shell in the container.

and explanation for -t flag from help page

-t, --tty Allocate a pseudo-TTY

if I delete -it flag during

docker run -d ubuntu:xenial /bin/bash

my newly created container doesn't live so much

in docker ps -a

it is designated as exited

Sorry, if my question quite stupid, I can't find explanation on the Internet (I have significant misunderstanding of that point).

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

-it is short for --interactive + --tty when you docker run with this command.. it would take you straight inside of the container,, where -d is short for --detach which means you just run the container and then detach from it so basically you run container in the background.. edit : so if you run docker container with-itd it would run the-it options and detach you from the container, so your container still running in the background even without any default app to run..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...