什么是docker run -it标志?
我正在使用docker做一些复杂的事情,但事实证明,我不知道 -it
标志的含义。
最近我遇到了 docker run
命令的一些示例,这使我有些困惑。
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
我的问题是什么意思如果容器在实例化期间运行 bin / bash
My question is what is sense to write -it
flag here, if container during instantiation run bin/bash
-it 标志>在文档中我们有一个例子
In documentation we have an example
docker run --name test -it debian
有解释
-它指示Docker分配一个伪TTY连接到
容器的标准输入在
容器中创建一个交互式bash shell。
The -it instructs Docker to allocate a pseudo-TTY connected to the container’s stdin; creating an interactive bash shell in the container.
并在帮助页面上提供-t标志的说明
and explanation for -t flag from help page
-t,--tty分配一个伪TTY
-t, --tty Allocate a pseudo-TTY
如果在删除过程中删除-it标志
if I delete -it flag during
docker run -d ubuntu:xenial /bin/bash
我新创建的容器没有那么多
my newly created container doesn't live so much
在 docker ps -a
被指定为已退出
抱歉,如果我的问题很愚蠢,我在Internet上找不到解释(对此我有很大的误解)。
Sorry, if my question quite stupid, I can't find explanation on the Internet (I have significant misunderstanding of that point).
-it
是的缩写-交互式+- tty
,当您使用此命令 docker运行
..它将直接带您进入容器内部,其中 -d
是-detach
的缩写,这意味着您只需运行容器,然后从中进行 detach ,因此基本上可以运行conta
编辑:,因此,如果您使用 -itd
运行docker容器,它将运行 -it
选项,将您从容器中分离出来,因此即使没有任何默认应用程序运行,您的容器仍在后台运行。
-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..