是否可以在正在运行的容器中启动 shell 会话(没有 ssh) [英] Is it possible to start a shell session in a running container (without ssh)

查看:23
本文介绍了是否可以在正在运行的容器中启动 shell 会话(没有 ssh)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我天真地希望这个命令在一个正在运行的容器中运行一个 bash shell:

I was naively expecting this command to run a bash shell in a running container :

docker run "id of running container" /bin/bash

看起来不可能,我收到错误:

it looks like it's not possible, I get the error :

2013/07/27 20:00:24 Internal server error: 404 trying to fetch remote history for 27d757283842

所以,如果我想在正在运行的容器中运行 bash shell(例如用于诊断目的)

So, if I want to run bash shell in a running container (ex. for diagnosis purposes)

我是否必须在其中运行 SSH 服务器并通过 ssh 登录?

do I have to run an SSH server in it and loggin via ssh ?

推荐答案

现在你可以使用 docker exec -it "id of running container" bash (doc)

Now you can use docker exec -it "id of running container" bash (doc)

以前,这个问题的答案是:

Previously, the answer to this question was:

如果你真的必须并且你在调试环境中,你可以这样做:sudo lxc-attach -n 请注意,id 必须是完整的(docker ps -notrunc).

If you really must and you are in a debug environment, you can do this: sudo lxc-attach -n <ID> Note that the id needs to be the full one (docker ps -notrunc).

但是,我强烈建议不要这样做.

However, I strongly recommend against this.

注意:-notrunc 已弃用,即将被 --no-trunc 取代.

notice: -notrunc is deprecated, it will be replaced by --no-trunc soon.

这篇关于是否可以在正在运行的容器中启动 shell 会话(没有 ssh)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆