码头附件vs lxc-attach [英] docker attach vs lxc-attach

查看:254
本文介绍了码头附件vs lxc-attach的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新:Docker 0.9.0现在使用libcontainer,从LXC转移请参阅:附加过程到Docker libcontainer容器

UPDATE: Docker 0.9.0 use libcontainer now, diverting from LXC see: Attaching process to Docker libcontainer container

我正在运行弹性搜索:

docker run -d -p 9200:9200 -p 9300:9300 dockerfile/elasticsearch

检查它显示的过程如下:

Checking the process it show like the following:

$ docker ps --no-trunc
CONTAINER ID                                                       IMAGE                             COMMAND                                           CREATED             STATUS              PORTS                                            NAMES
49fdccefe4c8c72750d8155bbddad3acd8f573bf13926dcaab53c38672a62f22   dockerfile/elasticsearch:latest   /usr/share/elasticsearch/bin/elasticsearch java   About an hour ago   Up 8 minutes        0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp   pensive_morse   

现在,当我尝试附加运行的容器时,我得到堆积:

Now, when I try to attach the running container, I get stacked:

$  sudo docker attach 49fdccefe4c8c72750d8155bbddad3acd8f573bf13926dcaab53c38672a62f22
[sudo] password for lsoave:

tty不连接,提示不回来。使用lxc-attach执行相同操作:

the tty doesn't connect and the prompt is not back. Doing the same with lxc-attach works fine:

$ sudo lxc-attach -n 49fdccefe4c8c72750d8155bbddad3acd8f573bf13926dcaab53c38672a62f22
root@49fdccefe4c8:/# ps -ef
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0 49 20:37 ?        00:00:20 /usr/bin/java -Xms256m -Xmx1g -Xss256k -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMa
root        88     0  0 20:38 ?        00:00:00 /bin/bash
root        92    88  0 20:38 ?        00:00:00 ps -ef
root@49fdccefe4c8:/# 

有谁知道码头附件怎么了?

Does anybody know what's wrong with docker attach ?

NB。 dockerfile / elasticsearch 结尾于:

ENTRYPOINT ["/usr/share/elasticsearch/bin/elasticsearch"]


推荐答案

您正在附加到运行 elasticsearch 的容器,而该容器不是交互式命令。你没有得到一个shell来输入,因为容器没有运行一个shell。原因 lxc-attach 的作用是因为它给你一个默认的shell。根据 man lxc-attach

You're attaching to a container that is running elasticsearch which isn't an interactive command. You don't get a shell to type in because the container is not running a shell. The reason lxc-attach works is because it's giving you a default shell. Per man lxc-attach:


如果未指定命令,则将在容器内查找用户
运行lxc-attach的当前默认shell,并执行
。如果容器
中没有这样的用户,或者容器没有工作的nsswitch机制,这将失败。

If no command is specified, the current default shell of the user running lxc-attach will be looked up inside the container and executed. This will fail if no such user exists inside the container or the container does not have a working nsswitch mechanism.

docker attach 的行为正如预期的那样。

docker attach is behaving as expected.

这篇关于码头附件vs lxc-attach的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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