gpt4 book ai didi

macos - docker 在 mac 上运行 ubuntu 没有任何反应

转载 作者:行者123 更新时间:2023-12-04 20:45:19 25 4
gpt4 key购买 nike

我在 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 shell ?

最佳答案

通过运行 docker run ubuntu /bin/bash , docker 从镜像 ubuntu 创建一个随机命名的容器并运行 bash没有 stdin , stdout也不是 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' is the bit that makes it interactive,
  • '--rm' removes the container when you exit (so if you want to be able to exit for detach and reattach later, do not do this), and
  • '--name' allows you to name the container more explicitly in case you want to run multiple instances of the same container

关于macos - docker 在 mac 上运行 ubuntu 没有任何反应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35740858/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com