2時間位ハマったのでメモしときましょう φ(..)メモメモ
KVMでCentOS7の仮想環境を作って、そこにdocker-machine create -d generic ~とやっていたんですが、sshでエラーコード127が返ってきていて、何がおきてるのかさっぱりわからずでハマりました。
こんな感じでエラーになってました。
(my-keystore) Calling .GetSSHHostname
(my-keystore) Calling .GetSSHPort
(my-keystore) Calling .GetSSHKeyPath
(my-keystore) Calling .GetSSHKeyPath
(my-keystore) Calling .GetSSHUsername
Using SSH client type: external
Using SSH private key: /home/masami/.docker/machine/machines/my-keystore/id_rsa (-rw-------)
&{[-F /dev/null -o BatchMode=yes -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none [email protected] -o IdentitiesOnly=yes -i /home/masami/.docker/machine/machines/my-keystore/id_rsa -p 22] /usr/bin/ssh <nil>}
Error running SSH command: exit status 127
(my-keystore) Calling .GetSSHHostname
(my-keystore) Calling .GetSSHPort
(my-keystore) Calling .GetSSHKeyPath
(my-keystore) Calling .GetSSHKeyPath
(my-keystore) Calling .GetSSHUsername
Using SSH client type: external
Using SSH private key: /home/masami/.docker/machine/machines/my-keystore/id_rsa (-rw-------)
&{[-F /dev/null -o BatchMode=yes -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none [email protected] -o IdentitiesOnly=yes -i /home/masami/.docker/machine/machines/my-keystore/id_rsa -p 22] /usr/bin/ssh <nil>}
Error running SSH command: exit status 127
Error creating machine: Error running provisioning: Unable to verify the Docker daemon is listening: Maximum number of retries (10) exceeded
open : no such file or directory
notifying bugsnag: [Error creating machine: Error running provisioning: Unable to verify the Docker daemon is listening: Maximum number of retries (10) exceeded]
まず、docker-machineでsshするときには↓のようなコマンドラインを組み立てます。鍵はdocker-machine create実行時に--generic-ssh-key ~/.ssh/id_ras_nopassで渡した秘密鍵が~/.docker/machine/machines/
ssh -F /dev/null -o BatchMode=yes -o PasswordAuthentication=no -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=quiet -o ConnectionAttempts=3 -o ConnectTimeout=10 -o ControlMaster=no -o ControlPath=none [email protected] -o IdentitiesOnly=yes -i /home/masami/.docker/machine/machines/my-keystore/id_rsa -p 22
使用している鍵はパスフレーズなしで、ユーザーはmasamiでsudoする時にパスワード不要で設定済みです。
上記のdocker-machineが作るコマンドラインでsshログインできるんだけど、sshコマンドで失敗するわけですね。CentOSがわでtailf /var/log/secureしていても怪しいログは出てきませんでした。そりゃnetstatの実行だけななので通常のユーザ権限でやってるし・・・
それでググって見つけたのがこちらです。
Unable to provision with generic driver (exit status 127) · Issue #2480 · docker/machine · GitHub
netstat入ってなくね?という質問に対して、issueを書いた人が「入れたらできた!」って言ってたので、net-toolsパッケージを入れたら難なく成功しました( ´Д`)=3 フゥ
Running pre-create checks... Creating machine... (my-keystore) Importing SSH key... Waiting for machine to be running, this may take a few minutes... Detecting operating system of created instance... Waiting for SSH to be available... Detecting the provisioner... Provisioning with centos... Copying certs to the local machine directory... Copying certs to the remote machine... Setting Docker configuration on the remote daemon... Checking connection to Docker... Docker is up and running! To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env my-keystore
ちなみにdocker-machineのコードだとlibmachine/provision/utils.goのcheckDaemonUp()でnetstat -tlnを実行しています。
( ´ー`)フゥー...

クラウド開発徹底攻略 (WEB+DB PRESS plus)
- 作者: 菅原元気,磯辺和彦,山口与力,澤登亨彦,内田誠悟,小林明大,石村真吾,相澤歩,柴田博志,伊藤直也,登尾徳誠,WEB+DB PRESS編集部
- 出版社/メーカー: 技術評論社
- 発売日: 2016/05/13
- メディア: 大型本
- この商品を含むブログを見る