docker运行在Mac上的Ubuntu和没有任何反应
我在Mac上运行:
docker is configured to use the default machine with IP 192.168.99.100 For help getting started, check out the docs at https://docs.docker.com my-mac:mydir$ docker run ubuntu /bin/bash my-mac:mydir$
难道我做错了什么? 我不应该进入ubuntu
壳?
通过运行docker run ubuntu /bin/bash
,docker从图像ubuntu创build一个随机命名的容器,并且运行一个bash
而不用stdin
, stdout
或者stderr
然后bash
退出(刚启动后)。
至less要设置一个tty和交互模式(又称为前景模式 ):
docker ps -a # if not exited, stop it first docker stop <container_id> # remove the container which cannot be used docker rm <container_id> # let's try again docker run -it --rm --name=test ubuntu bash
正如物理学家所评论的:
- “
-it
”是使它交互的位,- '
--rm
'当你退出时删除容器(所以如果你希望能够退出以后重新连接,不要这么做),以及- '
--name
'允许您更明确地命名容器,以防您想要运行同一个容器的多个实例
用下面的命令运行它
docker run -it ubuntu /bin/bash
然后你会得到Ubuntu容器的bash提示符