LoginSignup
3
0

More than 3 years have passed since last update.

docker-machine が xhyve で動かない(ことがありました)

Last updated at Posted at 2018-12-15

あらすじ

2018年11月上旬から2019年1月9日まで、macOS 上で xhyve を利用して docker-machine create すると Docker ホスト作成に失敗していた。これは、ドライバの docker-machine-driver-xhyve の問題ではなく、https://github.com/boot2docker/boot2docker/releases にある v18.09.0 の boot2docker.iso を macOS ではマウントできないため。1月10日にリリースされた v18.09.1 ではそのような問題は発生しない。

なお、hyperkit を利用して docker-machine create すると Docker ホスト作成に失敗するのは、また別の問題である。実際、minikube / minishift では、ドライバの docker-machine-driver-hyperkit を利用して Kubernetes / Openshift のクラスタを構築することができ、minikube docker-env / minishift docker-env を使って docker 関連の環境変数を設定すると、docker コマンドがちゃんと動く。

以下は、備忘録として残しておくことにする。

本来はこれでうまくいくはずなのだが...

docker-machine-driver-xhyve が入ってなければ、インストールする。brew でインストールしても、https://github.com/machine-drivers/docker-machine-driver-xhyve/releases からダウンロードしても、手間はあまり変わらない。

brew update
brew install docker-machine-driver-xhyve
sudo chown root:wheel /usr/local/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve
sudo chmod u+s /usr/local/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve

普通に docker-machive create してみる。

$ docker-machine create --driver xhyve test1
Running pre-create checks...
Creating machine...
(test1) Default Boot2Docker ISO is out-of-date, downloading the latest release...
(test1) Latest release for github.com/boot2docker/boot2docker is v18.09.0
(test1) Downloading /Users/xxxxxx/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v18.09.0/boot2docker.iso...
(test1) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
(test1) Copying /Users/xxxxxx/.docker/machine/cache/boot2docker.iso to /Users/xxxxxx/.docker/machine/machines/test1/boot2docker.iso...
(test1) Creating VM...
Error creating machine: Error in driver during machine creation: exit status 1

デバッグモードで調べてみると...

もう少し詳しい状況をみるために、debug mode で立ち上げてみる。その前に、ゴミを消す。

$ docker-machine rm test1
About to remove test1
WARNING: This action will delete both local reference and remote instance.
Are you sure? (y/n): y
Successfully removed test1

では、デバッグモードで起動。--debug の位置に注意。

$ docker-machine --debug create --driver xhyve test1
Docker Machine Version:  0.16.0, build 702c267f
Found binary path at /usr/local/bin/docker-machine-driver-xhyve
Launching plugin server for driver xhyve
Plugin server listening at address 127.0.0.1:54616

(長いので、中略)

(test1) DBG | local Boot2Docker ISO version:  
(test1) Default Boot2Docker ISO is out-of-date, downloading the latest release...
(test1) Latest release for github.com/boot2docker/boot2docker is v18.09.0
(test1) Downloading /Users/xxxxxx/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v18.09.0/boot2docker.iso...
(test1) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
(test1) DBG | Fix boot2docker.iso file permission...
(test1) Copying /Users/xxxxxx/.docker/machine/cache/boot2docker.iso to /Users/xxxxxx/.docker/machine/machines/test1/boot2docker.iso...
(test1) Creating VM...
(test1) DBG | Mounting boot2docker.iso
(test1) DBG | executing: &{/usr/bin/hdiutil [hdiutil attach /Users/xxxxxx/.docker/machine/machines/test1/boot2docker.iso -mountpoint /Users/xxxxxx/.docker/machine/machines/test1/b2d-image] []  <nil> 0xc000098008 0xc000098010 [] <nil> <nil> <nil> <nil> <nil> false [] [] [] [] <nil> <nil>} attach /Users/xxxxxx/.docker/machine/machines/test1/boot2docker.iso -mountpoint /Users/xxxxxx/.docker/machine/machines/test1/b2d-image
(test1) DBG | hdiutil: attach failed - no mountable file systems
Error creating machine: Error in driver during machine creation: exit status 1
notifying bugsnag: [Error creating machine: Error in driver during machine creation: exit status 1]

ダウンロードされた ISO イメージがマウントできない模様。~/.docker/machine/cache/boot2docker.iso をオープンすると、こんな感じで怒られる。
ScreenShot.png

boot2docker.iso が壊れているっぽいので...

https://github.com/boot2docker/boot2docker/releases を見てみると、v18.09.0 より新しい v18.09.1-rc1 があるので、これでトライ。

$ docker-machine rm test1
About to remove test1
WARNING: This action will delete both local reference and remote instance.
Are you sure? (y/n): y
Successfully removed test1

--xhyve-boot2docker-url で boot2docker.iso を直接指定する。

$ docker-machine create --driver xhyve --xhyve-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v18.09.1-rc1/boot2docker.iso test1
Running pre-create checks...
Creating machine...
(test1) Downloading /Users/xxxxxx/.docker/machine/cache/boot2docker.iso from https://github.com/boot2docker/boot2docker/releases/download/v18.09.1-rc1/boot2docker.iso...
(test1) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
(test1) Creating VM...
(test1) /dev/disk2                                              /Users/xxxxxx/.docker/machine/machines/test1/b2d-image
(test1) "disk2" ejected.
(test1) Generating 20000MB disk image...
(test1) created: /Users/xxxxxx/.docker/machine/machines/test1/root-volume.sparsebundle
(test1) Creating SSH key...
(test1) Fix file permission...
(test1) Generate UUID...
(test1) Convert UUID to MAC address...
(test1) Starting test1...
(test1) Waiting for VM to come online...
(test1) Waiting on a pseudo-terminal to be ready... done
(test1) Hook up your terminal emulator to /dev/ttys002 in order to connect to your VM
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 boot2docker...
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 test1
$ docker-machine ls
NAME    ACTIVE   DRIVER   STATE     URL                       SWARM   DOCKER         ERRORS
test1   -        xhyve    Running   tcp://192.168.64.6:2376           v18.09.1-rc1   

起動成功。早く、新しいバージョンがリリースされることが期待されています。

hyperkit ではどうか

docker-machine-driver-hyperkit というのがあり、minikube や minishift はこのドライバを使うことで、シングルノード構成のクラスタを立ち上げることができる。つまり、hyperkit ベースの Docker ホストを新たに生成して、kubernetes や openshift のクラスタを立ち上げている。

ということで、xhyve と同じように試してみるが、これはうまくいかない。

原因は、boot2docker の URL を指定する引数が、docker-machine-driver-hyperkit でうまく伝わらないためのように見える。ただ、minikube や minishift が立ち上がるわけだから、何か方法はありそう。

とりあえず、以上です。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0