我在 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/