Docker教程:4 hello world实例

2016-09-22  本文已影响0人  海涛666

英文原文:[https://docs.docker.com/engine/tutorials/dockerizing/]

运行一个Hello world容器

$ docker run ubuntu /bin/echo 'Hello world'
Hello world

这个示例中:

So what happened to the container after that? Well, Docker containers only run as long as the command you specify is active. Therefore, in the above example, the container stops once the command is executed.

docker容器什么时候结束是根据我们所指定的命令的运行情况决定的。

运行一个交互式容器

$ docker run -t -i ubuntu /bin/bash

-t
说明新的容器中包含一个虚拟的终端控制台
-i
说明这个命令是可交互式的(可以接收用户的输入)

容器启动后:

root@af8bae53bdd3:/#

我们可以输入一些/bin/bash中的命令进行测试:

root@af8bae53bdd3:/# pwd
/
root@af8bae53bdd3:/# ls
bin boot dev etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
上一篇 下一篇

猜你喜欢

热点阅读