docker的-it选项的作用

docker直接run,就是执行程序并退出:

$ docker run alpine sh

加上-i选项就是支持交互:

$ docker run -i alpine sh
ls
bin
dev
etc
home
lib
media
mnt
proc
root
run
sbin
srv
sys
tmp
usr
var
exit

再加上-t,就是进入终端:

$ docker run -it alpine sh
/ # uname
Linux
/ # exit

如果不是bash这样既有交互又有终端的程序,运行区别不大,都是运行完退出:

$ docker run -it alpine echo

以上。

My Github Page: https://github.com/liweinan

Powered by Jekyll and Theme by solid

If you have any question want to ask or find bugs regarding with my blog posts, please report it here:
https://github.com/liweinan/liweinan.github.io/issues