Docker - 使用新的TTY输入运行容器 [英] Docker - Enter Running Container with new TTY

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

问题描述

我有一个在前台运行Apache服务的容器。我希望能够从另一个shell访问容器,以便在其中戳并检查文件。目前,如果我附加到容器,我看着Apache守护程序,不能运行任何命令。



是否可以将另一个tty附加到正在运行的容器?可能的是,我可以利用Docker实际上只是围绕LXC容器的事实吗?我试过 sudo lxc-console -n [container-id] -t [1-4] ,但似乎只有一个tty可用,那就是一个运行apache守护进程。也许有一种方法可以在构建期间启用多个lxc控制台?



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

解决方案

使用docker 1.3,有一个新的命令 docker exec 。这可以让您进入正在运行的码头服务器:

  docker exec -it [container-id] bash 


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.

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?

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

解决方案

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

docker exec -it [container-id] bash

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

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