什么是 docker run -it 标志? [英] what is docker run -it flag?
问题描述
我正在用 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
在文档中我们有一个例子
In documentation we have an example
docker run --name test -it debian
附说明
-it 指示 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
它被指定为退出
对不起,如果我的问题很愚蠢,我在互联网上找不到解释(我对这一点有重大误解).
Sorry, if my question quite stupid, I can't find explanation on the Internet (I have significant misunderstanding of that point).
推荐答案
-it
是 --interactive + --tty
的缩写,当你 docker run 时
使用这个命令......它会带你直接进入容器,其中 -d
是 --detach
的缩写,这意味着你只需运行容器然后从它分离,所以基本上你在后台运行容器..所以如果你用-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..
这篇关于什么是 docker run -it 标志?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!