如何在 docker 容器中运行 /bin/bash?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/49666375/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to run /bin/bash in a docker container?
提问by kalitin.nikita
How to run /bin/bash
in a docker container that was started with the -d option
, for example:
如何在以 启动/bin/bash
的 docker 容器中运行-d option
,例如:
sudo docker run -P --name test-cnt3 -d base-tst:0.1?
I really need a console in the container and I already despaired of running it
我真的需要容器中的控制台,但我已经对运行它感到绝望
回答by Paul
Use docker execto run a command in an already running container, use -it
to create a new interactive pseudo-TTY:
使用docker exec在已经运行的容器中运行命令,用于-it
创建新的交互式伪 TTY:
docker exec -it test-cnt3 /bin/bash
回答by Arnaud
If you use docker-composer or Dockerfile look at Entrypoint & CMD
如果您使用 docker-composer 或 Dockerfile,请查看Entrypoint & CMD
And to connect use
sudo docker attach awesome-container
并连接使用
sudo docker attach awesome-container