如何输入已经运行了新TTY的Docker容器 [英] How to enter in a Docker container already running with a new TTY

查看:153
本文介绍了如何输入已经运行了新TTY的Docker容器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在前台运行Apache服务的容器。我希望能够从另一个外壳访问该容器,以便在其中探查并检查文件。目前,如果我附加到容器上,那么我将只看Apache守护程序,并且无法运行任何命令。

I have a container that is running the Apache service in the foreground. I would like to be able to access the container from another shell in order to "poke around" inside it and examine the files. At the moment, if I attach to the container, I am left looking at the Apache daemon and cannot run any commands.

是否可以在运行中附加另一个tty容器?可能地,我可以利用Docker实际上只是包裹LXC容器这一事实吗?我已经尝试过 sudo lxc-console -n [container-id] -t [1-4] ,但是看来只有一个tty可用,并且正在运行apache守护程序。也许有一种方法可以在构建过程中启用多个lxc控制台?

Is it possible to attach another tty to a running container? Possibly, I can take advantage of the fact that Docker is actually just wrapping around LXC containers? I have tried sudo lxc-console -n [container-id] -t [1-4] but it appears that only one tty is made available and that is the one running the apache daemon. Perhaps there is a way to enable multiple lxc consoles during the build?

我宁愿使用openssh服务配置和构建容器

I would rather not configure and build the container with an openssh service if possible.

推荐答案

对于docker 1.3,有一个新命令 docker exec 。这使您可以输入正在运行的容器:

With docker 1.3, there is a new command docker exec. This allows you to enter a running container:

docker exec -it [container-id] bash

这篇关于如何输入已经运行了新TTY的Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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