2019年11月

Unable to use a TTY - input is not a terminal or the right kind of file

環境 : Windows8.1

Minikube環境で動いているコンテナにGit Bashでkubectl exec -it simple-echo sh -c nginxとnginxのコンテナに入ろうとしたら以下のようなメッセージが出て入れず、Git Bashの応答がなくなりました。
$ kubectl exec -it simple-echo sh -c nginx
Unable to use a TTY - input is not a terminal or the right kind of file
とメッセージは少し違うのですが、winptyを先頭に追加した、無事コンテナに入れました(shできました)。
$ winpty kubectl exec -it simple-echo sh -c nginx
#
Git Bashのttyで怒られないように - Qiita
に記載のあるとおりexec winpty bashを実行して、bashをminttyからwinptyに変更する?(のかな…)といちいちwinpytと入力しなくてすみます。
$ exec winpty bash
$ kubectl exec -it simple-echo sh -c nginx
#

panic: runtime error: index out of range

Windows8でminikube startするとpanic: runtime error: index out of rangeでminikubeが起動できませんでした。
PS C:\Windows\system32> minikube start
* minikube v1.5.2 on Microsoft Windows 8.1 6.3.9600 Build 9600
* Creating hyperv VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
panic: runtime error: index out of range
理由は分からないのですが、以下のとおりminikube --vm-driver=virtualbox startと--vm-driverにvirtualboxを指定すると起動出来ました。
PS C:\Windows\system32> minikube --vm-driver=virtualbox start
* minikube v1.5.2 on Microsoft Windows 8.1 6.3.9600 Build 9600
* Creating virtualbox VM (CPUs=2, Memory=2000MB, Disk=20000MB) ...
* Found network options:
  - NO_PROXY=192.168.99.100,192.168.99.101,192.168.99.102,192.168.99.103
  - no_proxy=192.168.99.100,192.168.99.101,192.168.99.102,192.168.99.103
* Preparing Kubernetes v1.16.2 on Docker '18.09.9' ...
  - env NO_PROXY=192.168.99.100,192.168.99.101,192.168.99.102,192.168.99.103
  - env NO_PROXY=192.168.99.100,192.168.99.101,192.168.99.102,192.168.99.103
* Downloading kubeadm v1.16.2
* Downloading kubelet v1.16.2
* Pulling images ...
* Launching Kubernetes ...
* Waiting for: apiserver
* Done! kubectl is now configured to use "minikube"

curl: (7) Failed to connect to localhost port 9000: Connection refused

山田明憲著 『Docker/Kubernetes 実践コンテナ開発入門』 株式会社技術評論社 2018の2.1.1 Docker イメージとDockerコンテナの基本で以下のようにcurlコマンドが失敗しました。
$ curl http://localhost:8080/
curl: (7) Failed to connect to 192.168.99.100 port 8080: Connection refused
私の環境はWindows8.1なので、Docker for windowsが使えず、Docker Toolboxを使用しています。
Docker Toolboxを使用するとVirtualBoxにゲストOSが起動して、その上にDockerが動くので、VirtualBoxに起動しているゲストOSに割り振られたIPアドレスにアクセスする必要があります。

ゲストOSに割り振られたIPアドレスを調べるには、Docker Toolboxでdocker-machine lsを入力します。
$ docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER     ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v19.03.4
割り振られたIPSアドレスは192.168.99.100なので、以下のようにcurlコマンドを実行すると、無事Hello Docker!!が表示されます。
$ curl http://192.168.99.100:9000/
Hello Docker!!
参考 : Macでdockerを使う際にlocalhostでcontainerに繋げない問題の調査
記事検索