shell - 同时输入两个字母会导致 docker exec -it shell 突然退出

标签 shell docker docker-toolbox

我在 Windows 10 的 VirtualBox 上运行 Docker Toolbox。

我遇到了一个烦人的问题,如果我 docker exec -it mycontainer sh 进入容器 - 进行检查,shell 会突然随机退出到主机 shell,而我正在键入命令。一些实验表明,当我同时按下两个字母时(在触摸打字时很常见)会导致退出。

容器仍将运行。

任何想法这是什么?

更多详情

这是我在里面运行的一个最小的 docker 镜像。本质上,我正在尝试通过 kops 将 kubernetes 集群部署到 AWS,但是因为我在 Windows 上,所以我必须使用容器来运行 kops 命令。

FROM alpine:3.5

#install aws-cli
RUN apk add --no-cache \
  bind-tools\
  python \
 python-dev \
 py-pip \
 curl


RUN pip install awscli 

#install kubectl
RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
RUN chmod +x ./kubectl
RUN mv ./kubectl /usr/local/bin/kubectl


#install kops
RUN curl -LO https://github.com/kubernetes/kops/releases/download/$(curl -s https://api.github.com/repos/kubernetes/kops/releases/latest | grep tag_name | cut -d '"' -f 4)/kops-linux-amd64
RUN chmod +x kops-linux-amd64
RUN mv kops-linux-amd64 /usr/local/bin/kops

我构建了这个图像:

docker build -t mykube . 

我在我尝试部署的项目的工作目录中运行它:

docker run -dit -v "${PWD}":/app mykube

exec进入shell:

docker exec -it $containerid sh 

在 shell 中,我开始运行 AWS 命令​​ as per here .

这是一些示例输出:

##output of previous dig command 
;; Query time: 343 msec
;; SERVER: 10.0.2.3#53(10.0.2.3)
;; WHEN: Wed Feb 14 21:32:16 UTC 2018
;; MSG SIZE  rcvd: 188

##me entering a command
/ # aws s3 mb s3://clus
##shell exits abruptly to host shell while I'm writing
DavidJ@DavidJ-PC001 MINGW64 ~/git-workspace/webpack-react-express (master)
##container is still running 
$ docker ps --all
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
37a341cfde83        mykube              "/bin/sh"           5 minutes ago       Up 3 minutes                            gifted_bhaskara
##nothing in docker logs
$ docker logs --details 37a341cfde83

更有用的更新

添加 -D 标志提供了一个重要线索:

$ docker -D exec -it  04eef8107e91 sh -x
DEBU[0000] Error resize: Error response from daemon: no such exec
                                                                  / #
/ #
/ #
/ #
/ # sdfsdfjskfdDEBU[0006] [hijack] End of stdin
DEBU[0006] [hijack] End of stdout

另外,我已经确定导致问题的具体原因是同时按下两个字母(这在我触摸打字时很常见)。

似乎有一个 github issue for this here ,虽然这个是用于 windows 的 docker,而不是 docker 工具箱。

最佳答案

这个问题似乎是 docker 和 windows 的错误。 See the github issue here.

作为一种解决方法,在您的 docker exec 命令前面加上 git bash 附带的 winpty。

例如。

winpty docker exec -it mycontainer sh

关于shell - 同时输入两个字母会导致 docker exec -it shell 突然退出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48736249/

相关文章:

mysql - 使用GNU Parallel在shell脚本中并行执行多条sql语句

linux - 在 shell 脚本中执行命令时设置 LD_PRELOAD

php - Docker PHP - PECL 安装在使用 Heredoc 和 bash 时无法检测系统类型,但可以使用 SHELL 命令处理 shell 设置

docker - 如何从以前的安装中恢复容器?

linux - 如何以csv格式存储ps命令输出?

swift - 服务器端 Swift 的 LLDB 远程调试在 docker 和 macOS 中的 Linux 之间失败

docker - VMWare VIC(Photon OS + Docker)与 CoreOS + Docker

ubuntu - 验证在 Docker 容器中运行的 ubuntu 版本

linux - 区分目录名或目录路径