2016-03-02 101 views
3

我是在Mac上运行:泊坞窗Ubuntu运行情况

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壳?

回答

8

通过运行docker run ubuntu /bin/bash,码头工人从该映像创建Ubuntu的一个随机命名的容器中,并运行一个bash没有stdinstdout也不stderr然后bash退出(右启动后)。

尝试至少设置一个tty和交互模式(又名foreground mode):

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 

commented通过physincubus

  • '-it' 是,它使交互式的比特,
  • '--rm'当您退出时移除容器(因此如果您希望能够退出de转速表,稍后再连接,不这样做),并
  • --name”让你更明确命名容器的情况下,要运行相同的容器的多个实例
+0

@Auzias Thenk你。 bash退出的事实对我来说非常明显(没有交互模式),我没有提到它。 – VonC

+0

我毫无疑问地得到了那部分答案,因为答案是来自你的!但是,由于问题是关于“错误的”,我认为这会对@Jas – Auzias

+0

更有帮助,只是为了解释在这里绊倒的任何人的进一步信息'-it'是使它互动的一点,'--rm'当你退出时删除容器(所以如果你希望能够退出以后重新连接,不要这样做),'--name'允许你更明确地命名容器,以防你想运行多个实例同一个容器 – physincubus

0

与以下运行它命令

docker run -it ubuntu /bin/bash 

然后你会得到编辑的Ubuntu容器的bash提示符